GraphResourceRepository extends GraphGenericRepository<ResourceEntity> implements ResourceRepository, ResourceHierarchicalRepository { @Override public ResourceEntity getResourceWithInheritedAttributes(final ZoneEntity zone, final String resourceIdentifier) { return getEntityWithInheritedAttributes(zone, resourceIdentifier, Collections.emptySet()); }  @Override ResourceEntity getByZoneAndResourceIdentifier(final ZoneEntity zone, final String resourceIdentifier); @Override ResourceEntity getResourceWithInheritedAttributes(final ZoneEntity zone, final String resourceIdentifier); @Override Set<String> getResourceEntityAndDescendantsIds(final ResourceEntity entity); @Override List<S> findAll(final Example<S> example); @Override List<S> findAll(final Example<S> example, final Sort sort); @Override S findOne(final Example<S> example); @Override Page<S> findAll(final Example<S> example, final Pageable pageable); @Override long count(final Example<S> example); @Override boolean exists(final Example<S> example); static final String RESOURCE_LABEL; static final String RESOURCE_ID_KEY; }
@Test(threadPoolSize = CONCURRENT_TEST_THREAD_COUNT, invocationCount = CONCURRENT_TEST_INVOCATIONS) public void testGetResourceWithInheritedAttributesWithInheritedAttributes() { ResourceEntity resourceEntity1 = persist2LevelRandomResourcetoZone1(); ResourceEntity resource = this.resourceRepository .getResourceWithInheritedAttributes(TEST_ZONE_1, resourceEntity1.getResourceIdentifier()); assertThat(resource.getZone().getName(), equalTo(resourceEntity1.getZone().getName())); assertThat(resource.getResourceIdentifier(), equalTo(resourceEntity1.getResourceIdentifier())); assertThat(resource.getAttributes().contains(TYPE_MONSTER_OF_THE_WEEK), equalTo(true)); assertThat(resource.getAttributes().contains(SITE_BASEMENT), equalTo(true)); deleteTwoLevelEntityAndParents(resourceEntity1, TEST_ZONE_1, this.resourceRepository); }
@Test(threadPoolSize = CONCURRENT_TEST_THREAD_COUNT, invocationCount = CONCURRENT_TEST_INVOCATIONS) public void testGetByZoneAndResourceIdentifierWithInheritedAttributes3LevelHierarchical() { ResourceEntity expectedResource = persist3LevelRandomResourcetoZone1(); ResourceEntity actualResource = this.resourceRepository .getResourceWithInheritedAttributes(TEST_ZONE_1, expectedResource.getResourceIdentifier()); assertThat(actualResource.getAttributes().contains(SITE_BASEMENT), equalTo(true)); assertThat(actualResource.getAttributes().contains(TYPE_MONSTER_OF_THE_WEEK), equalTo(true)); assertThat(actualResource.getAttributes().contains(TOP_SECRET_CLASSIFICATION), equalTo(true)); deleteThreeLevelEntityAndParents(expectedResource, TEST_ZONE_1, this.resourceRepository); }
@Test(expectedExceptions = AttributeLimitExceededException.class, expectedExceptionsMessageRegExp = "The number of attributes on this resource .* has exceeded the maximum " + "limit of .*") public void testSearchAttributesTraversalLimitException() { long traversalLimit = 256L; try { ResourceEntity resource1 = persist3LevelRandomResourcetoZone1(); traversalLimit = this.resourceRepository.getTraversalLimit(); assertThat(traversalLimit, equalTo(256L)); this.resourceRepository.setTraversalLimit(2); assertThat(this.resourceRepository.getTraversalLimit(), equalTo(2L)); this.resourceRepository.getResourceWithInheritedAttributes(TEST_ZONE_1, resource1.getResourceIdentifier()); } finally { this.resourceRepository.setTraversalLimit(traversalLimit); assertThat(this.resourceRepository.getTraversalLimit(), equalTo(256L)); } }
@Test public void testSearchAttributesEqualsTraversalLimit() { long traversalLimit = 256L; try { traversalLimit = this.resourceRepository.getTraversalLimit(); assertThat(traversalLimit, equalTo(256L)); this.resourceRepository.setTraversalLimit(3); assertThat(this.resourceRepository.getTraversalLimit(), equalTo(3L)); ResourceEntity resource1 = persist3LevelRandomResourcetoZone1(); ResourceEntity actualResource = this.resourceRepository .getResourceWithInheritedAttributes(TEST_ZONE_1, resource1.getResourceIdentifier()); assertThat(actualResource.getAttributes().size(), equalTo(3)); } finally { this.resourceRepository.setTraversalLimit(traversalLimit); assertThat(this.resourceRepository.getTraversalLimit(), equalTo(256L)); } }