### Question:
WADLGenerator { Set<ClassMetadata> buildClassMetdata(Set<Class<?>> classes) { Set<ClassMetadata> metadataSet = new HashSet<ClassMetadata>(classes.size()); for (Class<?> c : classes) { if (!isResource(c)) { continue; } ClassMetadata metadata = ResourceMetadataCollector.collectMetadata(c); metadataSet.add(metadata); } return metadataSet; }  Application generate(String baseURI, Set<Class<?>> classes);  }### Answer:
@Test public void testBuildClassMetadataResource1() { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(Resource1.class); Set<ClassMetadata> metadataSet = generator.buildClassMetdata(classes); Assert.assertEquals(1, metadataSet.size()); ClassMetadata metadata = metadataSet.iterator().next(); assertEquals(Resource1.class.getAnnotation(Path.class).value(), metadata.getPath()); List<MethodMetadata> methodMetadata = metadata.getResourceMethods(); assertEquals(1, methodMetadata.size()); assertEquals(HttpMethod.GET, methodMetadata.get(0).getHttpMethod()); }
@Test public void testBuildClassMetadataResource2() { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(Resource2.class); Set<ClassMetadata> metadataSet = generator.buildClassMetdata(classes); Assert.assertEquals(1, metadataSet.size()); ClassMetadata metadata = metadataSet.iterator().next(); assertEquals(Resource2.class.getAnnotation(Path.class).value(), metadata.getPath()); List<MethodMetadata> methodMetadata = metadata.getResourceMethods(); assertEquals(2, methodMetadata.size()); assertEquals(HttpMethod.GET, methodMetadata.get(0).getHttpMethod()); assertEquals(HttpMethod.POST, methodMetadata.get(1).getHttpMethod()); }
@Test public void testBuildClassMetadata2Resources() { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(Resource1.class); classes.add(Resource2.class); Set<ClassMetadata> metadataSet = generator.buildClassMetdata(classes); Assert.assertEquals(2, metadataSet.size()); }
@Test public void testBuildClassMetadataNoResources() { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); Set<ClassMetadata> metadataSet = generator.buildClassMetdata(classes); Assert.assertEquals(0, metadataSet.size()); classes.add(NotAResourceWithPath.class); metadataSet = generator.buildClassMetdata(classes); Assert.assertEquals(0, metadataSet.size()); }