@Test(groups = "fast") public void testFixturesConfiguration() throws Exception { final String configPath = System.getProperty("java.io.tmpdir") + "/TestLegendConfigurationsManager-" + System.currentTimeMillis(); final String fixturesString = "" + " "formatDefault = function(y) {\n" + " if (y >= 1000000000000) { return y / 1000000000000 + \"T\" }-\n" + " else if (y >= 1000000000) { return y / 1000000000 + \"B\" }-\n" + " else if (y >= 1000000) { return y / 1000000 + \"M\" }-\n" + " else if (y >= 1000) { return y / 1000 + \"K\" }\n" + " else if (y < 1 && y > 0) { return y.toFixed(2) }\n" + " else if (y == 0) { return '' }\n" + " else { return y }\n" + "};\n" + "\n" + " "formatBase1024KMGTP = function(y) {\n" + " if (y >= 1125899906842624) { return y / 1125899906842624 + \"P\" }\n" + " else if (y >= 1099511627776){ return y / 1099511627776 + \"T\" }\n" + " else if (y >= 1073741824) { return y / 1073741824 + \"G\" }\n" + " else if (y >= 1048576) { return y / 1048576 + \"M\" }\n" + " else if (y >= 1024) { return y / 1024 + \"K\" }\n" + " else if (y < 1 && y > 0) { return y.toFixed(2) }\n" + " else if (y == 0) { return '' }\n" + " else { return y }\n" + "};"; Files.write(fixturesString, new File(configPath), Charsets.UTF_8); final DashboardConfig config = Mockito.mock(DashboardConfig.class); Mockito.when(config.getLegendFixturesFile()).thenReturn(configPath); final LegendConfigurationsManager manager = new LegendConfigurationsManager(config); final Map configuration = manager.getConfiguration(); Assert.assertEquals(configuration.size(), 2); Assert.assertEquals(((Map) configuration.get(LegendConfigurationsManager.LEGENDS_KEY)).size(), 0); Assert.assertEquals(configuration.get(LegendConfigurationsManager.FIXTURES_KEY), fixturesString); }
public Map getConfiguration() { final ImmutableMap.Builder builder = new ImmutableMap.Builder(); builder.put(LEGENDS_KEY, legendConfiguration); builder.put(FIXTURES_KEY, legendFixtures); return builder.build(); }
LegendConfigurationsManager { public Map getConfiguration() { final ImmutableMap.Builder builder = new ImmutableMap.Builder(); builder.put(LEGENDS_KEY, legendConfiguration); builder.put(FIXTURES_KEY, legendFixtures); return builder.build(); } }
LegendConfigurationsManager { public Map getConfiguration() { final ImmutableMap.Builder builder = new ImmutableMap.Builder(); builder.put(LEGENDS_KEY, legendConfiguration); builder.put(FIXTURES_KEY, legendFixtures); return builder.build(); } @Inject  LegendConfigurationsManager(final DashboardConfig config); }
LegendConfigurationsManager { public Map getConfiguration() { final ImmutableMap.Builder builder = new ImmutableMap.Builder(); builder.put(LEGENDS_KEY, legendConfiguration); builder.put(FIXTURES_KEY, legendFixtures); return builder.build(); } @Inject  LegendConfigurationsManager(final DashboardConfig config); Map getConfiguration(); }
LegendConfigurationsManager { public Map getConfiguration() { final ImmutableMap.Builder builder = new ImmutableMap.Builder(); builder.put(LEGENDS_KEY, legendConfiguration); builder.put(FIXTURES_KEY, legendFixtures); return builder.build(); } @Inject  LegendConfigurationsManager(final DashboardConfig config); Map getConfiguration(); static final String LEGENDS_KEY; static final String FIXTURES_KEY; }