@Test public void testGetResources() { AgEntity<Tr> entity = metadata.getAgEntity(Tr.class); Collection<AgResource<?>> resources = resourceMetadata.getAgResources(E5Resource.class); assertEquals(4, resources.size()); for (AgResource<?> resource : resources) { assertEquals(entity, resource.getEntity()); switch (resource.getPath()) { case "tr": assertEquals(LinkType.COLLECTION, resource.getType()); assertEquals(1, resource.getOperations().size()); assertEquals(LinkMethodType.GET, resource.getOperations().iterator().next().getMethod()); break; case "tr/{id}": assertEquals(LinkType.ITEM, resource.getType()); assertEquals(2, resource.getOperations().size()); for (AgOperation operation : resource.getOperations()) { switch (operation.getMethod()) { case GET: case DELETE: break; default: fail("Unexpected operation of type ITEM: " + operation.getMethod().name()); break; } } break; case "tr/md1": case "tr/md2": assertEquals(LinkType.METADATA, resource.getType()); assertEquals(1, resource.getOperations().size()); assertEquals(LinkMethodType.GET, resource.getOperations().iterator().next().getMethod()); break; default: { fail("Unexpected resource: " + resource.getPath()); } } } }
@Override public Collection<AgResource<?>> getAgResources(Class<?> resourceClass) { return classResources.computeIfAbsent(resourceClass, rc -> resourceParser.parse(rc)); }
ResourceMetadataService implements IResourceMetadataService { @Override public Collection<AgResource<?>> getAgResources(Class<?> resourceClass) { return classResources.computeIfAbsent(resourceClass, rc -> resourceParser.parse(rc)); } }
ResourceMetadataService implements IResourceMetadataService { @Override public Collection<AgResource<?>> getAgResources(Class<?> resourceClass) { return classResources.computeIfAbsent(resourceClass, rc -> resourceParser.parse(rc)); } ResourceMetadataService(@Inject IResourceParser resourceParser, @Inject BaseUrlProvider baseUrlProvider); }
ResourceMetadataService implements IResourceMetadataService { @Override public Collection<AgResource<?>> getAgResources(Class<?> resourceClass) { return classResources.computeIfAbsent(resourceClass, rc -> resourceParser.parse(rc)); } ResourceMetadataService(@Inject IResourceParser resourceParser, @Inject BaseUrlProvider baseUrlProvider); @Override Collection<AgResource<?>> getAgResources(Class<?> resourceClass); @Override Optional<String> getBaseUrl(); }
ResourceMetadataService implements IResourceMetadataService { @Override public Collection<AgResource<?>> getAgResources(Class<?> resourceClass) { return classResources.computeIfAbsent(resourceClass, rc -> resourceParser.parse(rc)); } ResourceMetadataService(@Inject IResourceParser resourceParser, @Inject BaseUrlProvider baseUrlProvider); @Override Collection<AgResource<?>> getAgResources(Class<?> resourceClass); @Override Optional<String> getBaseUrl();  }