Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- fixed broken test?
  • Loading branch information
temi committed Aug 19, 2024
1 parent 42fd1a6 commit d62b4c3
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/test/groovy/au/org/ala/ecodata/ProjectServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -943,13 +943,11 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
Site site2 = new Site(siteId: 's2', name: "Site 2", type: "compound", projects: ['111'], extent: [ source: "point", geometry: [intersectionAreaByFacets: ["elect": ["CURRENT": ["bean": 0.7, "canberra": 0.4, "fenner": 0.5]]]]]).save(flush: true, failOnError: true)
project1.metaClass.getDbo = { new BasicDBObject(project1.properties) }
session.flush()
projectMap = service.toMap(project1, ProjectService.ALL)
}
when:
Project.withSession {
result = service.orderLayerIntersectionsByAreaOfProjectSites(projectMap)
}
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.orderLayerIntersectionsByAreaOfProjectSites(projectMap)
then:
result.size() == 1
Expand All @@ -976,13 +974,11 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
site5 = new Site(siteId: 's5', name: "Site 5", type: "worksArea", projects: ['111'], extent: [ source: "point", geometry: [intersectionAreaByFacets: ["elect": ["CURRENT": ["bean": 0.7, "canberra": 0.4, "fenner": 0.5]]]]]).save(flush: true, failOnError: true)
project1.metaClass.getDbo = { new BasicDBObject(project1.properties) }
session.flush()
projectMap = service.toMap(project1, ProjectService.ALL)
}
when: // returns reporting and EMSA sites Only
Project.withSession {
result = service.getRepresentativeSitesOfProject(projectMap)
}
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
then:
result.size() == 3
Expand All @@ -997,11 +993,10 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
site2.type = Site.TYPE_WORKS_AREA
site2.save(flush: true)
site3.delete(flush: true)
project1.metaClass.getDbo = { new BasicDBObject(project1.properties) }
session.flush()
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
}
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
then:
result.size() == 3
Expand All @@ -1015,12 +1010,12 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
site1.save(flush: true)
site2.save(flush: true)
site5.save(flush: true)
project1.metaClass.getDbo = { new BasicDBObject(project1.properties) }
session.flush()
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
}
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
then:
result.size() == 1
result.siteId[0] == 's4'
Expand All @@ -1029,12 +1024,12 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
Project.withSession { session ->
project1.managementUnitId = null
project1.save(flush: true)
project1.metaClass.getDbo = { new BasicDBObject(project1.properties) }
session.flush()
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
}
projectMap = service.toMap(project1, ProjectService.ALL)
result = service.getRepresentativeSitesOfProject(projectMap)
then:
result.isEmpty()
}
Expand Down

0 comments on commit d62b4c3

Please sign in to comment.