### Question:
StandardExtendedURLResourceReferenceSerializer extends AbstractExtendedURLResourceReferenceSerializer { @Override public ExtendedURL serialize(ResourceReference reference) throws SerializeResourceReferenceException, UnsupportedResourceReferenceException { return serialize(reference, "standard"); }  @Override ExtendedURL serialize(ResourceReference reference);  }### Answer:
@Test public void serialize() throws Exception { TestResourceReference resource = new TestResourceReference(); ResourceReferenceSerializer serializer = mock(ResourceReferenceSerializer.class); ComponentManager componentManager = this.mocker.getInstance(ComponentManager.class, "context"); when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class), "standard")).thenReturn(serializer); this.mocker.getComponentUnderTest().serialize(resource); verify(serializer).serialize(same(resource)); }
@Test public void serializeWhenNoMatchingSerializer() throws Exception { TestResourceReference resource = new TestResourceReference(); ComponentManager componentManager = this.mocker.getInstance(ComponentManager.class, "context"); when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class), "standard")).thenThrow( new ComponentLookupException("error")); when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class))).thenThrow( new ComponentLookupException("error")); try { this.mocker.getComponentUnderTest().serialize(resource); fail("Should have thrown an exception here"); } catch (UnsupportedResourceReferenceException expected) { assertEquals("Failed to find serializer for Resource Reference [type = [test], parameters = []] and " + "URL format [standard]", expected.getMessage()); } }