use of org.codice.ddf.branding.BrandingPlugin in project ddf by codice.
the class TestLandingPage method setupLandingPage.
@BeforeClass
public static void setupLandingPage() throws IOException {
BrandingPlugin brandingPlugin = mock(BrandingPlugin.class);
when(brandingPlugin.getBase64FavIcon()).thenReturn("");
when(brandingPlugin.getBase64ProductImage()).thenReturn(Base64.getEncoder().encodeToString(fakeImg.getBytes()));
landingPage = new LandingPage();
BrandingRegistry branding = mock(BrandingRegistryImpl.class);
when(branding.getProductName()).thenReturn(productName);
when(branding.getProductVersion()).thenReturn(version);
when(branding.getBrandingPlugins()).thenReturn(Collections.singletonList(brandingPlugin));
when(branding.getAttributeFromBranding(any())).thenCallRealMethod();
landingPage.setBranding(branding);
String firstDateLeadingZeroes = "05/07/20 stuff happened";
String secondDateNoLeadingZeroes = "4/3/20 old stuff happened";
String noDate = "something happened";
List<String> unsorted = Arrays.asList(secondDateNoLeadingZeroes, noDate, firstDateLeadingZeroes);
sorted = Arrays.asList(firstDateLeadingZeroes, secondDateNoLeadingZeroes, noDate);
landingPage.setAnnouncements(unsorted);
}
use of org.codice.ddf.branding.BrandingPlugin in project ddf by codice.
the class PlatformUiConfigurationTest method testConfig.
@Test
public void testConfig() throws IOException {
PlatformUiConfiguration configuration = new PlatformUiConfiguration();
String wsOutput = configuration.getConfig();
// throws JSON Parse exception if not valid json.
Object obj = JSONValue.parse(wsOutput);
if (!(obj instanceof JSONObject)) {
fail("PlatformUiConfiguration is not a JSON Object.");
}
BrandingPlugin branding = mock(BrandingPlugin.class);
when(branding.getBase64FavIcon()).thenReturn(Base64.getEncoder().encodeToString("fav".getBytes()));
when(branding.getBase64ProductImage()).thenReturn(Base64.getEncoder().encodeToString("image".getBytes()));
BrandingRegistryImpl brandingPlugin = mock(BrandingRegistryImpl.class);
when(brandingPlugin.getProductName()).thenReturn("product");
when(brandingPlugin.getBrandingPlugins()).thenReturn(Collections.singletonList(branding));
when(brandingPlugin.getAttributeFromBranding(any())).thenCallRealMethod();
configuration.setBranding(brandingPlugin);
configuration.setHeader("header");
configuration.setFooter("footer");
configuration.setBackground("background");
configuration.setColor("color");
wsOutput = configuration.getConfig();
// throws JSON Parse exception if not valid json.
obj = JSONValue.parse(wsOutput);
if (!(obj instanceof JSONObject)) {
fail("PlatformUiConfiguration is not a JSON Object.");
}
JSONObject jsonObject = (JSONObject) obj;
assertEquals("header", jsonObject.get(PlatformUiConfiguration.HEADER));
assertEquals("footer", jsonObject.get(PlatformUiConfiguration.FOOTER));
assertEquals("background", jsonObject.get(PlatformUiConfiguration.BACKGROUND));
assertEquals("color", jsonObject.get(PlatformUiConfiguration.COLOR));
assertEquals("product", jsonObject.get(PlatformUiConfiguration.TITLE));
assertEquals("image", new String(Base64.getMimeDecoder().decode((String) jsonObject.get(PlatformUiConfiguration.PRODUCT_IMAGE))));
assertEquals("fav", new String(Base64.getMimeDecoder().decode((String) jsonObject.get(PlatformUiConfiguration.FAV_ICON))));
}
Aggregations