@Test public void testBuildBasicMethodMetadataWithMock() throws Exception { WADLGenerator generator = new WADLGenerator(); Mockery mockContext = new Mockery() { { setImposteriser(ClassImposteriser.INSTANCE); } }; final MethodMetadata metadata = mockContext.mock(MethodMetadata.class); final ClassMetadata classMeta = mockContext.mock(ClassMetadata.class); final java.lang.reflect.Method method = BasicResourceWithVoidReturn.class.getMethod("basicReturn"); mockContext.checking(new Expectations() { { oneOf(metadata).getHttpMethod(); will(returnValue("myHttpMethod")); oneOf(metadata).getFormalParameters(); will(returnValue(null)); oneOf(metadata).getProduces(); will(returnValue(Collections.emptySet())); exactly(2).of(metadata).getReflectionMethod(); will(returnValue(method)); } }); Method m = generator.buildMethod(classMeta, metadata); assertEquals("myHttpMethod", m.getName()); assertEquals(0, m.getDoc().size()); assertEquals(0, m.getAny().size()); assertNull(m.getHref()); assertNull(m.getId()); assertNull(m.getRequest()); assertEquals(1, m.getResponse().size()); List<Response> resps = m.getResponse(); assertEquals(Collections.singletonList(Long.valueOf(204)), resps.get(0).getStatus()); assertEquals(0, resps.get(0).getAny().size()); assertEquals(0, resps.get(0).getDoc().size()); assertEquals(0, resps.get(0).getOtherAttributes().size()); assertEquals(0, resps.get(0).getParam().size()); mockContext.assertIsSatisfied(); }
Method buildMethod(ClassMetadata classMetadata, MethodMetadata metadata) { Method m = new Method(); m.setName(metadata.getHttpMethod()); java.lang.reflect.Method reflMethod = metadata.getReflectionMethod(); if (reflMethod != null) { WADLDoc d = reflMethod.getAnnotation(WADLDoc.class); if (d != null) { m.getDoc().add(getDocument(d)); } } Request r = buildRequest(classMetadata, metadata); if (r != null) { m.setRequest(r); } List<Response> resp = buildResponse(metadata); if (resp != null) { m.getResponse().addAll(resp); } return m; }
WADLGenerator { Method buildMethod(ClassMetadata classMetadata, MethodMetadata metadata) { Method m = new Method(); m.setName(metadata.getHttpMethod()); java.lang.reflect.Method reflMethod = metadata.getReflectionMethod(); if (reflMethod != null) { WADLDoc d = reflMethod.getAnnotation(WADLDoc.class); if (d != null) { m.getDoc().add(getDocument(d)); } } Request r = buildRequest(classMetadata, metadata); if (r != null) { m.setRequest(r); } List<Response> resp = buildResponse(metadata); if (resp != null) { m.getResponse().addAll(resp); } return m; } }
WADLGenerator { Method buildMethod(ClassMetadata classMetadata, MethodMetadata metadata) { Method m = new Method(); m.setName(metadata.getHttpMethod()); java.lang.reflect.Method reflMethod = metadata.getReflectionMethod(); if (reflMethod != null) { WADLDoc d = reflMethod.getAnnotation(WADLDoc.class); if (d != null) { m.getDoc().add(getDocument(d)); } } Request r = buildRequest(classMetadata, metadata); if (r != null) { m.setRequest(r); } List<Response> resp = buildResponse(metadata); if (resp != null) { m.getResponse().addAll(resp); } return m; }  }
WADLGenerator { Method buildMethod(ClassMetadata classMetadata, MethodMetadata metadata) { Method m = new Method(); m.setName(metadata.getHttpMethod()); java.lang.reflect.Method reflMethod = metadata.getReflectionMethod(); if (reflMethod != null) { WADLDoc d = reflMethod.getAnnotation(WADLDoc.class); if (d != null) { m.getDoc().add(getDocument(d)); } } Request r = buildRequest(classMetadata, metadata); if (r != null) { m.setRequest(r); } List<Response> resp = buildResponse(metadata); if (resp != null) { m.getResponse().addAll(resp); } return m; }  Application generate(String baseURI, Set<Class<?>> classes); }
WADLGenerator { Method buildMethod(ClassMetadata classMetadata, MethodMetadata metadata) { Method m = new Method(); m.setName(metadata.getHttpMethod()); java.lang.reflect.Method reflMethod = metadata.getReflectionMethod(); if (reflMethod != null) { WADLDoc d = reflMethod.getAnnotation(WADLDoc.class); if (d != null) { m.getDoc().add(getDocument(d)); } } Request r = buildRequest(classMetadata, metadata); if (r != null) { m.setRequest(r); } List<Response> resp = buildResponse(metadata); if (resp != null) { m.getResponse().addAll(resp); } return m; }  Application generate(String baseURI, Set<Class<?>> classes);  }