Search in sources :

Example 1 with IndyAddOnID

use of org.commonjava.indy.model.spi.IndyAddOnID in project indy by Commonjava.

the class IndyAddOnIDTest method roundTripSerialize.

@Test
public void roundTripSerialize() throws Exception {
    final UIRoute route = new UIRoute("/foo", "/partials/foo.html");
    final UISection section = new UISection("Foo (Add-On)", route.getRoute());
    final IndyAddOnID id = new IndyAddOnID().withName("foo").withInitJavascriptHref("js/foo.js").withRoute(route).withSection(section);
    final String json = mapper.writeValueAsString(id);
    logger.info(json);
    final IndyAddOnID result = mapper.readValue(json, IndyAddOnID.class);
    assertThat(result.getName(), equalTo(id.getName()));
    assertThat(result.getInitJavascriptHref(), equalTo(id.getInitJavascriptHref()));
    final List<UIRoute> rRoutes = result.getRoutes();
    assertThat(rRoutes, notNullValue());
    assertThat(rRoutes.size(), equalTo(1));
    final UIRoute rRoute = rRoutes.get(0);
    assertThat(rRoute.getTemplateHref(), equalTo(route.getTemplateHref()));
    assertThat(rRoute.getRoute(), equalTo(route.getRoute()));
    final List<UISection> rSections = result.getSections();
    assertThat(rSections, notNullValue());
    assertThat(rSections.size(), equalTo(1));
    final UISection rSection = rSections.get(0);
    assertThat(rSection.getName(), equalTo(section.getName()));
    assertThat(rSection.getRoute(), equalTo(section.getRoute()));
}
Also used : UISection(org.commonjava.indy.model.spi.UISection) UIRoute(org.commonjava.indy.model.spi.UIRoute) IndyAddOnID(org.commonjava.indy.model.spi.IndyAddOnID) Test(org.junit.Test)

Example 2 with IndyAddOnID

use of org.commonjava.indy.model.spi.IndyAddOnID in project indy by Commonjava.

the class StatsController method getActiveAddOns.

public AddOnListing getActiveAddOns() {
    final List<IndyAddOnID> ids = new ArrayList<IndyAddOnID>();
    if (addons != null) {
        logger.info("Getting list of installed add-ons...");
        for (final IndyAddOn addon : addons) {
            final IndyAddOnID id = addon.getId();
            logger.info("Adding {}", id);
            ids.add(id);
        }
    }
    return new AddOnListing(ids);
}
Also used : AddOnListing(org.commonjava.indy.model.spi.AddOnListing) IndyAddOn(org.commonjava.indy.spi.IndyAddOn) ArrayList(java.util.ArrayList) IndyAddOnID(org.commonjava.indy.model.spi.IndyAddOnID)

Aggregations

IndyAddOnID (org.commonjava.indy.model.spi.IndyAddOnID)2 ArrayList (java.util.ArrayList)1 AddOnListing (org.commonjava.indy.model.spi.AddOnListing)1 UIRoute (org.commonjava.indy.model.spi.UIRoute)1 UISection (org.commonjava.indy.model.spi.UISection)1 IndyAddOn (org.commonjava.indy.spi.IndyAddOn)1 Test (org.junit.Test)1