use of com.zimbra.doc.soap.changelog.CommandChanges in project zm-mailbox by Zimbra.
the class ChangelogTest method makeChangelogTest.
@Test
public void makeChangelogTest() throws Exception {
Map<String, ApiClassDocumentation> javadocInfo = Maps.newTreeMap();
List<Class<?>> classes = Lists.newArrayList();
classes.add(aRequest.class);
classes.add(aResponse.class);
classes.add(bRequest.class);
classes.add(bResponse.class);
classes.add(cRequest.class);
classes.add(cResponse.class);
Root soapApiDataModelRoot = WsdlDocGenerator.processJaxbClasses(javadocInfo, classes);
SoapApiDescription jsonDescCurrent = new SoapApiDescription("7.99.99", "20000131-2359");
jsonDescCurrent.build(soapApiDataModelRoot);
// File json = new File("/tmp/test1.json");
// jsonDescCurrent.serializeToJson(json);
InputStream is = getClass().getResourceAsStream("baseline1.json");
SoapApiDescription jsonDescBaseline = SoapApiDescription.deserializeFromJson(is);
SoapApiChangeLog clog = new SoapApiChangeLog();
clog.setBaselineDesc(jsonDescBaseline);
clog.setCurrentDesc(jsonDescCurrent);
clog.makeChangeLogDataModel();
List<SoapApiCommand> newCmds = clog.getNewCommands();
LOG.info(" New Command:" + newCmds.get(0).getName());
List<SoapApiCommand> delCmds = clog.getDeletedCommands();
LOG.info(" Deleted Command:" + delCmds.get(0).getName());
List<CommandChanges> modCmds = clog.getModifiedCommands();
CommandChanges modCmd = modCmds.get(0);
LOG.info(" Modified Command:" + modCmd.getName());
List<NamedAttr> delAttrs = modCmd.getDeletedAttrs();
for (NamedAttr attr : delAttrs) {
LOG.info(" Deleted Attribute:" + attr.getXpath());
}
List<NamedAttr> addAttrs = modCmd.getNewAttrs();
for (NamedAttr attr : addAttrs) {
LOG.info(" Added Attribute:" + attr.getXpath());
}
List<AttributeChanges> modAttrs = modCmd.getModifiedAttrs();
for (AttributeChanges modAttr : modAttrs) {
LOG.info(" Modified Attribute " + modAttr.getXpath() + ":\nbase=" + modAttr.getBaselineRepresentation() + "\ncurr=" + modAttr.getCurrentRepresentation());
}
List<NamedElem> delEs = modCmd.getDeletedElems();
for (NamedElem el : delEs) {
LOG.info(" Deleted Element :" + el.getXpath());
}
List<NamedElem> newEs = modCmd.getNewElems();
for (NamedElem el : newEs) {
LOG.info(" New Element :" + el.getXpath());
}
List<ElementChanges> modEs = modCmd.getModifiedElements();
for (ElementChanges el : modEs) {
LOG.info(" Modified Element " + el.getXpath() + ":\nbase=" + el.getBaselineRepresentation() + "\ncurr=" + el.getCurrentRepresentation());
}
Assert.assertEquals("Number of new commands", 1, newCmds.size());
Assert.assertEquals("Number of deleted commands", 1, delCmds.size());
Assert.assertEquals("Number of modified commands", 1, modCmds.size());
Assert.assertEquals("Number of deleted attributes", 1, delAttrs.size());
Assert.assertEquals("Number of new attributes", 1, addAttrs.size());
Assert.assertEquals("Number of modified attributes", 1, modAttrs.size());
Assert.assertEquals("Number of deleted elements", 1, delEs.size());
Assert.assertEquals("Number of new elements", 1, newEs.size());
Assert.assertEquals("Number of modified elements", 1, modEs.size());
}
Aggregations