public void testClientPackageFor() throws Exception {
BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
HashMap<String, String> conversions = new HashMap<String, String>();
conversions.put("org.codehaus.enunciate.samples", "red.herring");
conversions.put("org.codehaus.enunciate.samples.xfire_client.with.a.nested", "org.codehaus.enunciate.other.pckg.and.nested");
ClientPackageForMethod packageForMethod = new ClientPackageForMethod(conversions);
TypeDeclaration typeDeclaration = getDeclaration("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.NestedPackageClass");
assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(typeDeclaration))));
assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(typeDeclaration.getPackage()))));
assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg.plus.extra", packageForMethod.exec(Arrays.asList(wrapper.wrap("org.codehaus.enunciate.samples.xfire_client.with.a.nested.pckg.plus.extra"))));
assertEquals("red.herring.xfire_client", packageForMethod.exec(Arrays.asList(wrapper.wrap("org.codehaus.enunciate.samples.xfire_client"))));
for (FieldDeclaration fieldDeclaration : typeDeclaration.getFields()) {
if ("items".equals(fieldDeclaration.getSimpleName())) {
assertEquals("java.util", packageForMethod.exec(Arrays.asList(wrapper.wrap(fieldDeclaration.getType()))));
}
else if ("type".equals(fieldDeclaration.getSimpleName())) {
assertEquals("org.codehaus.enunciate.other.pckg.and.nested.pckg", packageForMethod.exec(Arrays.asList(wrapper.wrap(fieldDeclaration.getType()))));
}
}
}