Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Ryhmä25 SuperBugTracker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MarkmanAndTheBoys
Ryhmä25 SuperBugTracker
Commits
7ac6edc5
Commit
7ac6edc5
authored
3 years ago
by
santerhs
Browse files
Options
Downloads
Patches
Plain Diff
add tests for project
parent
cdc66971
Branches
create-project
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/Model/Project.java
+12
-0
12 additions, 0 deletions
src/main/java/Model/Project.java
src/test/java/Model/ProjectTest.java
+48
-0
48 additions, 0 deletions
src/test/java/Model/ProjectTest.java
with
60 additions
and
0 deletions
src/main/java/Model/Project.java
+
12
−
0
View file @
7ac6edc5
...
...
@@ -11,6 +11,12 @@ public class Project {
name
=
_name
;
}
public
Project
(
int
_id
,
String
_name
,
Team
_team
)
{
id
=
_id
;
name
=
_name
;
team
=
_team
;
}
public
Project
(){}
public
int
getId
()
{
...
...
@@ -36,4 +42,10 @@ public class Project {
public
void
setTeam
(
Team
team
)
{
this
.
team
=
team
;
}
public
boolean
validate
()
throws
Exception
{
if
(
this
.
getName
()
==
null
||
this
.
getName
().
equals
(
""
))
throw
new
Exception
(
"Name must be defined for new project"
);
if
(
this
.
getTeam
()
==
null
||
this
.
getTeam
().
getId
()
==
0
)
throw
new
Exception
(
"Team must be defined for new project"
);
return
true
;
}
}
This diff is collapsed.
Click to expand it.
src/test/java/Model/ProjectTest.java
0 → 100644
+
48
−
0
View file @
7ac6edc5
package
Model
;
import
org.junit.jupiter.api.Test
;
import
java.util.Date
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
public
class
ProjectTest
{
private
Team
team
=
new
Team
(
1
,
"Markman and the boys"
);
private
Project
fullProject
=
new
Project
(
1
,
"SuperBugTracker"
,
team
);
private
Project
noTeamProject
=
new
Project
(
1
,
"SuperBugTracker"
,
null
);
private
Project
noNameProject
=
new
Project
(
1
,
null
,
team
);
@Test
public
void
validateWorkingProject
()
{
try
{
assertTrue
(
fullProject
.
validate
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
@Test
public
void
validateProjectWithMissingTeam
()
{
Exception
exception
=
assertThrows
(
Exception
.
class
,
()
->
{
noTeamProject
.
validate
();
});
String
expectedMessage
=
"Team must be defined for new project"
;
String
actualMessage
=
exception
.
getMessage
();
assertTrue
(
actualMessage
.
contains
(
expectedMessage
));
}
@Test
public
void
validateProjectWithMissingName
()
{
Exception
exception
=
assertThrows
(
Exception
.
class
,
()
->
{
noNameProject
.
validate
();
});
String
expectedMessage
=
"Name must be defined for new project"
;
String
actualMessage
=
exception
.
getMessage
();
assertTrue
(
actualMessage
.
contains
(
expectedMessage
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment