Search in sources :

Example 1 with SoapApiDescription

use of com.zimbra.doc.soap.apidesc.SoapApiDescription in project zm-mailbox by Zimbra.

the class ZmApiDoclet method start.

/**
     * Starts processing the classes at the root document
     *
     * @param root the root document
     * @throws IOException 
     * @throws SoapDocException 
     */
public static boolean start(RootDoc root) throws IOException, SoapDocException {
    if (apiListener == null) {
        setListener(new DocletApiListener());
    }
    apiListener.processJavadocResults(root);
    // map between class name and associated documentation
    Map<String, ApiClassDocumentation> javadocInfo = apiListener.getDocMap();
    readOptions(root.options());
    Root soapApiDataModelRoot = WsdlDocGenerator.processJaxbClasses(javadocInfo);
    // process FreeMarker templates
    Properties templateContext = new Properties();
    templateContext.setProperty(TemplateHandler.PROP_TEMPLATES_DIR, templatesDir);
    templateContext.setProperty(TemplateHandler.PROP_OUTPUT_DIR, outputDir);
    templateContext.setProperty(TemplateHandler.PROP_BUILD_VERSION, buildVersion);
    templateContext.setProperty(TemplateHandler.PROP_BUILD_DATE, buildDate);
    // generate the API Reference documentation
    ApiReferenceTemplateHandler templateHandler = new ApiReferenceTemplateHandler(templateContext);
    templateHandler.process(soapApiDataModelRoot);
    // generate a JSON representation of the API used when creating a changelog
    SoapApiDescription jsonDesc = new SoapApiDescription(buildVersion, buildDate);
    jsonDesc.build(soapApiDataModelRoot);
    File json = new File(apiDescriptionJson);
    jsonDesc.serializeToJson(json);
    return true;
}
Also used : ApiReferenceTemplateHandler(com.zimbra.doc.soap.template.ApiReferenceTemplateHandler) Root(com.zimbra.doc.soap.Root) SoapApiDescription(com.zimbra.doc.soap.apidesc.SoapApiDescription) Properties(java.util.Properties) File(java.io.File) ApiClassDocumentation(com.zimbra.doc.soap.ApiClassDocumentation)

Example 2 with SoapApiDescription

use of com.zimbra.doc.soap.apidesc.SoapApiDescription 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());
}
Also used : AttributeChanges(com.zimbra.doc.soap.changelog.AttributeChanges) InputStream(java.io.InputStream) NamedElem(com.zimbra.doc.soap.changelog.CommandChanges.NamedElem) SoapApiChangeLog(com.zimbra.doc.soap.changelog.SoapApiChangeLog) NamedAttr(com.zimbra.doc.soap.changelog.CommandChanges.NamedAttr) CommandChanges(com.zimbra.doc.soap.changelog.CommandChanges) ElementChanges(com.zimbra.doc.soap.changelog.ElementChanges) BeforeClass(org.junit.BeforeClass) SoapApiCommand(com.zimbra.doc.soap.apidesc.SoapApiCommand) SoapApiDescription(com.zimbra.doc.soap.apidesc.SoapApiDescription) Test(org.junit.Test)

Aggregations

SoapApiDescription (com.zimbra.doc.soap.apidesc.SoapApiDescription)2 ApiClassDocumentation (com.zimbra.doc.soap.ApiClassDocumentation)1 Root (com.zimbra.doc.soap.Root)1 SoapApiCommand (com.zimbra.doc.soap.apidesc.SoapApiCommand)1 AttributeChanges (com.zimbra.doc.soap.changelog.AttributeChanges)1 CommandChanges (com.zimbra.doc.soap.changelog.CommandChanges)1 NamedAttr (com.zimbra.doc.soap.changelog.CommandChanges.NamedAttr)1 NamedElem (com.zimbra.doc.soap.changelog.CommandChanges.NamedElem)1 ElementChanges (com.zimbra.doc.soap.changelog.ElementChanges)1 SoapApiChangeLog (com.zimbra.doc.soap.changelog.SoapApiChangeLog)1 ApiReferenceTemplateHandler (com.zimbra.doc.soap.template.ApiReferenceTemplateHandler)1 File (java.io.File)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1