use of ddf.action.MultiActionProvider in project ddf by codice.
the class AdminPollerTest method testAllSourceInfo.
@Test
public void testAllSourceInfo() {
Action operatorActionOne = getTestAction("operationIdOne", "operationTitle1", "operationDescription1", "https://localhost:8993/provider/someAction");
Action operatorActionTwo = getTestAction("operationIdTwo", "operationTitleTwo", "operationDescriptionTwo", "https://localhost:8993/provider/someAction");
ImmutableList<MultiActionProvider> operationActions = ImmutableList.of(getHandleableTestActionProvider(operatorActionOne), getNotHandleableTestActionProvider(), getHandleableTestActionProvider(operatorActionTwo));
poller.setOperationActionProviders(operationActions);
Action reportActionOne = getTestAction("reportId", "reportTitle", "reportDescription", "https://localhost:8993/provider/someAction");
ImmutableList<MultiActionProvider> reportActions = ImmutableList.of(getHandleableTestActionProvider(reportActionOne), getNotHandleableTestActionProvider(), getNotHandleableTestActionProvider());
poller.setReportActionProviders(reportActions);
List<Map<String, Object>> sources = poller.allSourceInfo();
assertThat(sources, notNullValue());
assertThat(sources.size(), is(2));
assertThat(sources.get(0), not(hasKey("configurations")));
assertThat(sources.get(1), hasKey("configurations"));
List<Map<String, Object>> configurations = (List) sources.get(1).get("configurations");
assertThat(configurations, hasSize(1));
Map<String, Object> configurationMap = configurations.get(0);
assertThat(configurationMap, hasKey("operation_actions"));
assertThat(configurationMap, hasKey("report_actions"));
List<Map<String, Object>> operationActionsList = (List) configurationMap.get("operation_actions");
Map<String, String> operatorActionOneMap = getMapFromAction(operatorActionOne);
Map<String, String> operatorActionTwoMap = getMapFromAction(operatorActionTwo);
assertThat(operationActionsList, contains(operatorActionOneMap, operatorActionTwoMap));
List<Map<String, Object>> reportActionsList = (List) configurationMap.get("report_actions");
Map<String, String> reportActionMap = getMapFromAction(reportActionOne);
assertThat(reportActionsList, contains(reportActionMap));
}
use of ddf.action.MultiActionProvider in project ddf by codice.
the class AdminPollerServiceBean method getActions.
private List<Map<String, String>> getActions(Configuration config, List<MultiActionProvider> providers) {
List<Map<String, String>> actions = new ArrayList<>();
for (MultiActionProvider provider : providers) {
if (!provider.canHandle(config)) {
continue;
}
List<Action> curActionList = provider.getActions(config);
for (Action action : curActionList) {
Map<String, String> actionProperties = new HashMap<>();
actionProperties.put(MAP_ENTRY_ACTION_ID, action.getId());
actionProperties.put(MAP_ENTRY_ACTION_TITLE, action.getTitle());
actionProperties.put(MAP_ENTRY_ACTION_DESCRIPTION, action.getDescription());
actionProperties.put(MAP_ENTRY_ACTION_URL, action.getUrl().toString());
actions.add(actionProperties);
}
}
return actions;
}
use of ddf.action.MultiActionProvider in project ddf by codice.
the class AdminPollerTest method getHandleableTestActionProvider.
private MultiActionProvider getHandleableTestActionProvider(Action action) {
MultiActionProvider actionProvider = mock(MultiActionProvider.class);
when(actionProvider.canHandle(any(Configuration.class))).thenReturn(true);
when(actionProvider.getActions(any(Class.class))).thenReturn(CollectionUtils.asList(action));
return actionProvider;
}
use of ddf.action.MultiActionProvider in project ddf by codice.
the class AdminPollerTest method getNotHandleableTestActionProvider.
private MultiActionProvider getNotHandleableTestActionProvider() {
MultiActionProvider actionProvider = mock(MultiActionProvider.class);
when(actionProvider.canHandle(any(Configuration.class))).thenReturn(false);
return actionProvider;
}
Aggregations