### Question:
WADLGenerator { public Application generate(String baseURI, Set<Class<?>> classes) { Application app = new Application(); if (classes == null || classes.isEmpty()) { return app; } Resources resources = new Resources(); resources.setBase(baseURI); Set<ClassMetadata> metadataSet = buildClassMetdata(classes); resources.getResource().addAll(buildResources(metadataSet)); app.getResources().add(resources); return app; }  Application generate(String baseURI, Set<Class<?>> classes);  }### Answer:
@Test public void testGenerate1Resource() throws Exception { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(Resource1.class); classes.add(Resource2.class); classes.add(MyInterface.class); Application app = generator.generate("", classes); Assert.assertNotNull(app); marshalIt(app); }
@Test public void testWADLDocResource1() throws Exception { WADLGenerator generator = new WADLGenerator(); Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(Resource1.class); Application app = generator.generate("", classes); Resource res = app.getResources().get(0).getResource().get(0); assertEquals(1, res.getDoc().size()); assertEquals("this is resource1 title", res.getDoc().get(0).getTitle()); assertEquals(res.getDoc().get(0).getContent().size(), 1); assertEquals("this is resource1 content", res.getDoc().get(0).getContent().get(0)); Method m = (Method)res.getMethodOrResource().get(0); assertEquals(1, m.getDoc().size()); assertEquals("this is the hello method with only default title value and no content", m.getDoc().get(0) .getTitle()); assertEquals(0, m.getDoc().get(0).getContent().size()); assertEquals(1, m.getRequest().getDoc().size()); assertEquals("request doc", m.getRequest().getDoc().get(0).getTitle()); boolean isFound = false; List<Param> params = m.getRequest().getParam(); for (Param p : params) { if (p.getName().equals("q2")) { isFound = true; assertEquals(1, p.getDoc().size()); assertEquals("q2 parameter doc", p.getDoc().get(0).getTitle()); } else { assertEquals(0, p.getDoc().size()); } } assertTrue(isFound); }
@Test public void testGenerateEmptyApp() throws Exception { WADLGenerator generator = new WADLGenerator(); Application app = generator.generate(null, null); Assert.assertNotNull(app); Assert.assertEquals(0, app.getAny().size()); Assert.assertEquals(0, app.getDoc().size()); Assert.assertEquals(0, app.getResources().size()); Assert.assertEquals(0, app.getResourceTypeOrMethodOrRepresentation().size()); Assert.assertNull(app.getGrammars()); }