use of org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData in project ovirt-engine by oVirt.
the class WebAdminHostPageServletTest method testGetPluginDefinitionsArray.
@Test
public void testGetPluginDefinitionsArray() {
int mockDataCount = 10;
List<PluginData> pluginData = new ArrayList<>();
for (int i = 0; i < mockDataCount; i++) {
PluginData mockData = mock(PluginData.class);
// $NON-NLS-1$
when(mockData.getName()).thenReturn("name" + i);
// $NON-NLS-1$
when(mockData.getUrl()).thenReturn("url" + i);
when(mockData.mergeConfiguration()).thenReturn(mock(ObjectNode.class));
when(mockData.isEnabled()).thenReturn(true);
pluginData.add(mockData);
}
ArrayNode result = testServlet.getPluginDefinitionsArray(pluginData);
assertEquals(mockDataCount, result.size());
for (int i = 0; i < mockDataCount; i++) {
JsonNode item = result.get(i);
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals(item.get("name").asText(), "name" + i);
// $NON-NLS-1$ //$NON-NLS-2$
assertEquals(item.get("url").asText(), "url" + i);
// $NON-NLS-1$
assertTrue(item.get("config") instanceof ObjectNode);
// $NON-NLS-1$
assertTrue(item.get("enabled").asBoolean());
}
}
use of org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData in project ovirt-engine by oVirt.
the class WebAdminHostPageServlet method getPluginDefinitionsArray.
protected ArrayNode getPluginDefinitionsArray(List<PluginData> pluginData) {
ArrayNode arr = createArrayNode();
for (PluginData data : pluginData) {
ObjectNode dataObj = createObjectNode();
// $NON-NLS-1$
dataObj.put("name", data.getName());
// $NON-NLS-1$
dataObj.put("url", data.getUrl());
// $NON-NLS-1$
dataObj.put("config", data.mergeConfiguration());
// $NON-NLS-1$
dataObj.put("lazyLoad", data.isLazyLoad());
// $NON-NLS-1$
dataObj.put("enabled", data.isEnabled());
arr.add(dataObj);
}
return arr;
}
Aggregations