Skip to content

Commit

Permalink
[SHIBUI-2249]
Browse files Browse the repository at this point in the history
fix concurrent modification problem in test
  • Loading branch information
jj committed Nov 3, 2021
1 parent 9a76083 commit 518880f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -133,7 +134,7 @@ public String getModifiedDate() {
@JsonIgnore
public LocalDateTime getModifiedDateAsDate() {
// we shouldn't have an ED without either modified or created date, so this is mostly for testing where data can be odd
return modifiedDate != null ? modifiedDate : createdDate != null ? createdDate : LocalDateTime.now();
return modifiedDate != null ? modifiedDate : createdDate != null ? createdDate : LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
}

public OrganizationRepresentation getOrganization() {
Expand Down Expand Up @@ -246,4 +247,4 @@ public void setServiceProviderSsoDescriptor(ServiceProviderSsoDescriptorRepresen
public void setVersion(int version) {
this.version = version;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -596,12 +596,14 @@ class EntityDescriptorControllerTests extends AbstractBaseDataJpaTest {
@WithMockAdmin
def "PUT /EntityDescriptor updates entity descriptors properly as admin"() {
given:
def entityDescriptorTwo = new EntityDescriptor(resourceId: 'uuid-2', entityID: 'eid2', serviceProviderName: 'sp2', serviceEnabled: false, idOfOwner: Group.ADMIN_GROUP.getOwnerId())
def entityDescriptorToSave = new EntityDescriptor(resourceId: 'uuid-2', entityID: 'eid2', serviceProviderName: 'sp2', serviceEnabled: false, idOfOwner: Group.ADMIN_GROUP.getOwnerId())
entityDescriptorTwo = entityDescriptorRepository.save(entityDescriptorTwo)
entityDescriptorRepository.save(entityDescriptorToSave)
entityManager.flush()
entityManager.clear()
def entityDescriptorTwo = entityDescriptorRepository.findByResourceId('uuid-2')
def updatedEntityDescriptorRepresentation = jpaEntityDescriptorService.createRepresentationFromDescriptor(entityDescriptorTwo)
updatedEntityDescriptorRepresentation.setServiceProviderName("newName")
def postedJsonBody = mapper.writeValueAsString(updatedEntityDescriptorRepresentation)
Expand Down Expand Up @@ -689,4 +691,4 @@ class EntityDescriptorControllerTests extends AbstractBaseDataJpaTest {
e instanceof ConcurrentModificationException
}
}
}
}

0 comments on commit 518880f

Please sign in to comment.