Search in sources :

Example 1 with UIRoute

use of org.commonjava.indy.model.spi.UIRoute 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)

Aggregations

IndyAddOnID (org.commonjava.indy.model.spi.IndyAddOnID)1 UIRoute (org.commonjava.indy.model.spi.UIRoute)1 UISection (org.commonjava.indy.model.spi.UISection)1 Test (org.junit.Test)1