Skip to content

Commit

Permalink
SHIBUI-1740
Browse files Browse the repository at this point in the history
Fix for broken tests
  • Loading branch information
chasegawa committed Jul 6, 2021
1 parent 525f7c6 commit bbe62ab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import edu.internet2.tier.shibboleth.admin.ui.configuration.Internationalization
import edu.internet2.tier.shibboleth.admin.ui.configuration.SearchConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.TestConfiguration
import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor
import edu.internet2.tier.shibboleth.admin.ui.exception.EntityNotFoundException
import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository
import edu.internet2.tier.shibboleth.admin.ui.repository.envers.EnversTestsSupport
import edu.internet2.tier.shibboleth.admin.ui.service.EntityDescriptorService
Expand Down Expand Up @@ -108,15 +109,20 @@ class EnversEntityDescriptorVersionServiceTests extends Specification {
v2EdRepresentation.id == ed.resourceId
}

def "versioning service returns null for non existent version number"() {
def "versioning service throws EntityNotFoundException for non existent version number"() {
when: 'Initial version'
EntityDescriptor ed = new EntityDescriptor(entityID: 'ed', serviceProviderName: 'SP1', createdBy: 'anonymousUser')
ed = edu.internet2.tier.shibboleth.admin.ui.repository.envers.EnversTestsSupport.doInExplicitTransaction(txMgr) {
entityDescriptorRepository.save(ed)
}
def edRepresentation = entityDescriptorVersionService.findSpecificVersionOfEntityDescriptor(ed.resourceId, '1000')


then:
!edRepresentation
try {
def edRepresentation = entityDescriptorVersionService.findSpecificVersionOfEntityDescriptor(ed.resourceId, '1000')
1 == 2
}
catch (EntityNotFoundException expected) {
1 == 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Role(String name, int rank) {
private String name;

@Column(name = "ROLE_RANK")
private int rank;
private int rank; // 0=ADMIN, additional ranks are higher

//Ignore properties annotation here is to prevent stack overflow recursive error during JSON serialization
@JsonIgnoreProperties("roles")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public interface EntityDescriptorVersionService {

List<Version> findVersionsForEntityDescriptor(String resourceId) throws EntityNotFoundException;

EntityDescriptorRepresentation findSpecificVersionOfEntityDescriptor(String resourceId, String versionId);
EntityDescriptorRepresentation findSpecificVersionOfEntityDescriptor(String resourceId, String versionId) throws EntityNotFoundException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ public List<Version> findVersionsForEntityDescriptor(String resourceId) throws E
}

@Override
public EntityDescriptorRepresentation findSpecificVersionOfEntityDescriptor(String resourceId, String versionId) {
public EntityDescriptorRepresentation findSpecificVersionOfEntityDescriptor(String resourceId, String versionId) throws EntityNotFoundException {
Object edObject = enversVersionServiceSupport.findSpecificVersionOfPersistentEntity(resourceId, versionId, EntityDescriptor.class);
return edObject == null ? null : entityDescriptorService.createRepresentationFromDescriptor((EntityDescriptor) edObject);
if (edObject == null) {
throw new EntityNotFoundException("Unable to find specific version requested - version: " + versionId);
}
return entityDescriptorService.createRepresentationFromDescriptor((EntityDescriptor) edObject);
}
}

0 comments on commit bbe62ab

Please sign in to comment.