DATAREST-1105 - Polishing.
Simplified code a bit. Formatting. Adapted integration tests to make sure URI templates are always expanded. Original pull request: #273.
This commit is contained in:
@@ -45,6 +45,7 @@ import org.springframework.hateoas.Link;
|
||||
* Unit tests for {@link Associations}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Haroun Pacquee
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AssociationLinksUnitTests {
|
||||
@@ -61,7 +62,9 @@ public class AssociationLinksUnitTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
doReturn(projectionDefinitionConfig).when(config).getProjectionConfiguration();
|
||||
|
||||
this.mappingContext = new KeyValueMappingContext<>();
|
||||
this.entity = mappingContext.getRequiredPersistentEntity(Sample.class);
|
||||
this.mappings = new PersistentEntitiesResourceMappings(new PersistentEntities(Arrays.asList(mappingContext)));
|
||||
|
||||
@@ -133,11 +133,14 @@ public class AssociationsUnitTests {
|
||||
assertThat(links).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test // DATAREST-1105
|
||||
public void detectsProjectionsForAssociationLinks() {
|
||||
|
||||
String projectionParameterName = "projection";
|
||||
|
||||
doReturn(true).when(projectionDefinitionConfiguration).hasProjectionFor(RelatedAndExported.class);
|
||||
doReturn(projectionParameterName).when(projectionDefinitionConfiguration).getParameterName();
|
||||
|
||||
List<Link> links = associations.getLinksFor(getAssociation(Root.class, "relatedAndExported"), new Path(""));
|
||||
|
||||
assertThat(links).hasSize(1);
|
||||
@@ -162,4 +165,4 @@ public class AssociationsUnitTests {
|
||||
static class RelatedAndExported {}
|
||||
|
||||
static class RelatedButNotExported {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user