use of ddf.action.Action 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.Action 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.Action in project ddf by codice.
the class AdminPollerTest method getTestAction.
private Action getTestAction(String id, String title, String description, String urlString) {
Action action = mock(Action.class);
when(action.getId()).thenReturn(id);
when(action.getTitle()).thenReturn(title);
when(action.getDescription()).thenReturn(description);
try {
URL url = new URL(urlString);
when(action.getUrl()).thenReturn(url);
} catch (MalformedURLException e) {
// do nothing
}
return action;
}
use of ddf.action.Action in project ddf by codice.
the class AbstractMetacardActionProviderTest method getActionsWhenSubclassCannotHandleMetacard.
@Test
public void getActionsWhenSubclassCannotHandleMetacard() throws Exception {
MetacardActionProvider actionProvider = createMetacardActionProvider();
when(actionProvider.canHandleMetacard(metacard)).thenReturn(false);
Action action = actionProvider.getAction(metacard);
assertThat(action, is(nullValue()));
verify(actionProvider, never()).getMetacardAction(any(), any());
}
use of ddf.action.Action in project ddf by codice.
the class AbstractMetacardActionProviderTest method getActionsWithNonMetacard.
@Test
public void getActionsWithNonMetacard() throws Exception {
MetacardActionProvider actionProvider = createMetacardActionProvider();
Action action = actionProvider.getAction("blah");
assertThat(action, is(nullValue()));
verify(actionProvider, never()).getMetacardAction(any(), any());
}
Aggregations