Skip to content

Commit

Permalink
Correct environment fetching in the repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe444 committed Feb 11, 2021
1 parent 4eede9f commit ba22801
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private Environment toEnvironment(EnvironmentTuple environmentTuple) {
.findAny();

if (foundSpace.isPresent()) {
spaces.remove(foundSpace.get());
Set<ServiceId> serviceIds = new HashSet<>(foundSpace.get().getServiceIds());
serviceIds.add(new ServiceId(serviceVersion.getName(), serviceVersion.getVersion()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class JPAEnvironmentRepositoryIT extends Specification {
noExceptionThrown()
}

def 'should overwrite what was persisted before'() {
def 'should overwrite what was persisted before - multiple environments'() {
given:
def environment1 = repository.persist(new Environment(
'environmentName',
Expand All @@ -54,6 +54,35 @@ class JPAEnvironmentRepositoryIT extends Specification {
}
}

def 'should get persisted environment with multiple spaces'() {
given:
def firstSpace = new Space('a', [new ServiceId('serviceName1', 'serviceVersion1')] as Set)

and:
def secondSpace = new Space('b', [
new ServiceId('serviceName2', 'serviceVersion2'),
new ServiceId('serviceName3', 'serviceVersion3'),
new ServiceId('serviceName4', 'serviceVersion4')
] as Set)

and:
def thirdSpace = new Space('def', [new ServiceId('serviceName5', 'serviceVersion5')] as Set)

and:
def environment = new Environment('environmentName', [firstSpace, secondSpace, thirdSpace] as Set)

when:
repository.persist(environment)

then:
def storedEnvironment = repository.get('environmentName')
storedEnvironment.name == 'environmentName'
storedEnvironment.spaces.size() == 3
storedEnvironment.spaces.contains(firstSpace)
storedEnvironment.spaces.contains(secondSpace)
storedEnvironment.spaces.contains(thirdSpace)
}

def 'should retrieve names'() {
given:
def environment1 = repository.persist(new Environment(
Expand Down

0 comments on commit ba22801

Please sign in to comment.