Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Team 5 - Smart Towns
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Rhys Evans
Team 5 - Smart Towns
Commits
e321e10b
Commit
e321e10b
authored
1 year ago
by
Rhys Evans
Browse files
Options
Downloads
Patches
Plain Diff
Further work on getting JUnit test to work
parent
545d2602
No related branches found
Branches containing commit
No related tags found
1 merge request
!34
Resolve "As a user, I would like a town specific page which shows all trails for that town so that I can easily see my progress"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java
+32
-9
32 additions, 9 deletions
...est/java/Team5/SmartTowns/SmartTownsApplicationTests.java
with
32 additions
and
9 deletions
src/test/java/Team5/SmartTowns/SmartTownsApplicationTests.java
+
32
−
9
View file @
e321e10b
...
...
@@ -3,35 +3,57 @@ package Team5.SmartTowns;
import
Team5.SmartTowns.Data.Location
;
import
Team5.SmartTowns.Data.Town
;
import
Team5.SmartTowns.Data.TownRepository
;
import
Team5.SmartTowns.Data.locationRepositoryJDBC
;
import
Team5.SmartTowns.Towns.TownController
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.jdbc.JdbcTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.RowMapper
;
import
org.springframework.test.context.jdbc.Sql
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
java.util.List
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertSame
;
import
static
org
.
mockito
.
Mockito
.
mock
;
@SpringBootTest
@JdbcTest
@Sql
({
"schema.sql"
,
"data.sql"
})
class
SmartTownsApplicationTests
{
private
static
TownController
townController
;
@Autowired
private
Team5
.
SmartTowns
.
Data
.
locationRepository
locationRepository
;
private
Team5
.
SmartTowns
.
Data
.
Location
location
;
private
static
Team5
.
SmartTowns
.
Data
.
Location
location
;
// @Mock
// private static JdbcTemplate jdbc;
@Autowired
private
Team5
.
SmartTowns
.
Data
.
locationRepository
locationRepo
;
JdbcTemplate
jdbc
=
Mockito
.
mock
(
JdbcTemplate
.
class
);
@Autowired
private
Team5
.
SmartTowns
.
Data
.
TownRepository
townRepository
;
private
static
Team5
.
SmartTowns
.
Data
.
TownRepository
townRepository
;
private
static
Team5
.
SmartTowns
.
Data
.
Location
town
;
private
static
RowMapper
<
Location
>
locationMapper
;
private
Team5
.
SmartTowns
.
Data
.
Location
town
;
@BeforeAll
public
static
void
before
()
{
locationRepositroy
=
new
location
.
locationRepository
();
public
void
before
()
{
// MockitoAnnotations.initMocks(this);
location
=
new
Location
();
locationRepo
=
mock
(
new
locationRepositoryJDBC
(
jdbc
));
townController
=
new
TownController
();
}
// @BeforeAll
// public static void before(){}
...
...
@@ -44,12 +66,13 @@ class SmartTownsApplicationTests {
@Test
public
void
whenFilteringTownsByLocationsReturnOneTown
()
{
List
<
Location
>
allLocations
=
locationRepo
sitory
.
getAllLocation
();
List
<
Location
>
allLocations
=
(
locationRepo
.
getAllLocation
()
)
;
List
<
Town
>
allTowns
=
townRepository
.
getAllTowns
();
int
allLocationNumber
=
allLocations
.
size
();
int
allLocationNumberAfterFilter
=
0
;
for
(
Town
town
:
allTowns
){
allLocationNumberAfterFilter
+=
townController
.
filterByLocationForTrails
(
allLocations
,
town
.
getTownName
()).
size
();
allLocationNumberAfterFilter
+=
townController
.
filterByLocationForTrails
(
allLocations
,
town
.
getTownName
()).
size
();
}
assertSame
(
allLocationNumber
,
allLocationNumberAfterFilter
);
/// list of all locations,
...
...
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