### Question:
RadiologyModalityResource extends MetadataDelegatingCrudResource<RadiologyModality> { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display"); description.addProperty("aeTitle"); description.addProperty("name"); description.addProperty("description"); description.addProperty("retired"); description.addSelfLink(); if (rep instanceof DefaultRepresentation) { description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); } else { description.addProperty("auditInfo"); } return description; } return null; }  @Override String getResourceVersion(); @Override DelegatingResourceDescription getRepresentationDescription(Representation rep); @Override DelegatingResourceDescription getCreatableProperties(); @PropertyGetter("display") String getDisplayString(RadiologyModality delegate); @Override RadiologyModality getByUniqueId(String uniqueId); @Override RadiologyModality newDelegate(); @Override RadiologyModality save(RadiologyModality delegate); @Override void delete(RadiologyModality delegate, String reason, RequestContext context); @Override void purge(RadiologyModality delegate, RequestContext context);  }### Answer:
@Test public void shouldReturnDefaultRepresentationGivenInstanceOfDefaultrepresentation() throws Exception { DefaultRepresentation defaultRepresentation = new DefaultRepresentation(); DelegatingResourceDescription resourceDescription = radiologyModalityResource.getRepresentationDescription(defaultRepresentation); assertThat(resourceDescription.getProperties() .keySet(), contains("uuid", "display", "aeTitle", "name", "description", "retired")); }
@Test public void shouldReturnFullRepresentationGivenInstanceOfFullrepresentation() throws Exception { FullRepresentation fullRepresentation = new FullRepresentation(); DelegatingResourceDescription resourceDescription = radiologyModalityResource.getRepresentationDescription(fullRepresentation); assertThat(resourceDescription.getProperties() .keySet(), contains("uuid", "display", "aeTitle", "name", "description", "retired", "auditInfo")); }
@Test public void shouldReturnNullForRepresentationOtherThenDefaultOrFull() throws Exception { CustomRepresentation customRepresentation = new CustomRepresentation("some"); assertThat(radiologyModalityResource.getRepresentationDescription(customRepresentation), is(nullValue())); NamedRepresentation namedRepresentation = new NamedRepresentation("some"); radiologyModalityResource = new RadiologyModalityResource(); assertThat(radiologyModalityResource.getRepresentationDescription(namedRepresentation), is(nullValue())); RefRepresentation refRepresentation = new RefRepresentation(); radiologyModalityResource = new RadiologyModalityResource(); assertThat(radiologyModalityResource.getRepresentationDescription(refRepresentation), is(nullValue())); }