Search in sources :

Example 1 with Converter

use of org.craftercms.commons.converters.Converter in project engine by craftercms.

the class NavTreeBuilderImplTest method getItemConverter.

private Converter<SiteItem, NavItem> getItemConverter() {
    Converter<SiteItem, NavItem> converter = mock(Converter.class);
    doAnswer((Answer<NavItem>) invocation -> {
        SiteItem siteItem = (SiteItem) invocation.getArguments()[0];
        NavItem navItem = new NavItem();
        navItem.setLabel(siteItem.getStoreName());
        navItem.setUrl(siteItem.getStoreUrl());
        return navItem;
    }).when(converter).convert(any(SiteItem.class));
    return converter;
}
Also used : ItemFilter(org.craftercms.core.service.ItemFilter) Answer(org.mockito.stubbing.Answer) Mockito(org.mockito.Mockito) Arrays(java.util.Arrays) Converter(org.craftercms.commons.converters.Converter) SiteItem(org.craftercms.engine.model.SiteItem) SiteItemService(org.craftercms.engine.service.SiteItemService) Test(org.junit.Test) NavItem(org.craftercms.engine.navigation.NavItem) Assert(org.junit.Assert) FilenameUtils(org.apache.commons.io.FilenameUtils) Before(org.junit.Before) NavItem(org.craftercms.engine.navigation.NavItem) SiteItem(org.craftercms.engine.model.SiteItem)

Aggregations

Arrays (java.util.Arrays)1 FilenameUtils (org.apache.commons.io.FilenameUtils)1 Converter (org.craftercms.commons.converters.Converter)1 ItemFilter (org.craftercms.core.service.ItemFilter)1 SiteItem (org.craftercms.engine.model.SiteItem)1 NavItem (org.craftercms.engine.navigation.NavItem)1 SiteItemService (org.craftercms.engine.service.SiteItemService)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1