Search in sources :

Example 1 with PluginData

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());
    }
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) PluginData(org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData) ArrayList(java.util.ArrayList) JsonNode(org.codehaus.jackson.JsonNode) ArrayNode(org.codehaus.jackson.node.ArrayNode) Test(org.junit.Test)

Example 2 with PluginData

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;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) PluginData(org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData) ArrayNode(org.codehaus.jackson.node.ArrayNode)

Aggregations

ArrayNode (org.codehaus.jackson.node.ArrayNode)2 ObjectNode (org.codehaus.jackson.node.ObjectNode)2 PluginData (org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData)2 ArrayList (java.util.ArrayList)1 JsonNode (org.codehaus.jackson.JsonNode)1 Test (org.junit.Test)1