Search in sources :

Example 36 with Action

use of ddf.action.Action in project ddf by codice.

the class AbstractMetacardActionProviderTest method getActionsWithMetacardThatHasNullId.

@Test
public void getActionsWithMetacardThatHasNullId() throws Exception {
    MetacardActionProvider actionProvider = createMetacardActionProvider();
    when(metacard.getId()).thenReturn(null);
    Action action = actionProvider.getAction(metacard);
    assertThat(action, is(nullValue()));
    verify(actionProvider, never()).getMetacardAction(any(), any());
}
Also used : Action(ddf.action.Action) Test(org.junit.Test)

Example 37 with Action

use of ddf.action.Action in project ddf by codice.

the class AbstractMetacardActionProviderTest method getActionsWithNull.

@Test
public void getActionsWithNull() throws Exception {
    MetacardActionProvider actionProvider = createMetacardActionProvider();
    Action action = actionProvider.getAction(null);
    assertThat(action, is(nullValue()));
    verify(actionProvider, never()).getMetacardAction(any(), any());
}
Also used : Action(ddf.action.Action) Test(org.junit.Test)

Example 38 with Action

use of ddf.action.Action in project ddf by codice.

the class AbstractMetacardActionProviderTest method getActionsWhenHostNotSet.

@Test
public void getActionsWhenHostNotSet() throws Exception {
    MetacardActionProvider actionProvider = createMetacardActionProvider();
    when(actionProvider.canHandleMetacard(metacard)).thenReturn(true);
    when(actionProvider.createMetacardAction(eq(ACTION_ID), eq(TITLE), eq(DESCRIPTION), any())).thenReturn(action);
    when(actionProvider.getMetacardActionUrl(SOURCE_ID, metacard)).thenReturn(url);
    System.clearProperty(SystemBaseUrl.HOST);
    Action action = actionProvider.getAction(metacard);
    assertThat(action, is(this.action));
    verify(actionProvider).createMetacardAction(ACTION_ID, TITLE, DESCRIPTION, url);
}
Also used : Action(ddf.action.Action) Test(org.junit.Test)

Example 39 with Action

use of ddf.action.Action in project ddf by codice.

the class TestKMLTransformerImpl method setUp.

@BeforeClass
public static void setUp() throws IOException {
    when(mockContext.getBundle()).thenReturn(mockBundle);
    URL url = TestKMLTransformerImpl.class.getResource(DEFAULT_STYLE_LOCATION);
    when(mockBundle.getResource(any(String.class))).thenReturn(url);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    ActionProvider mockActionProvider = mock(ActionProvider.class);
    Action mockAction = mock(Action.class);
    when(mockActionProvider.getAction(any(Metacard.class))).thenReturn(mockAction);
    when(mockAction.getUrl()).thenReturn(new URL(ACTION_URL));
    kmlTransformer = new KMLTransformerImpl(mockContext, DEFAULT_STYLE_LOCATION, new KmlStyleMap(), mockActionProvider);
}
Also used : ActionProvider(ddf.action.ActionProvider) Action(ddf.action.Action) Metacard(ddf.catalog.data.Metacard) LineString(de.micromata.opengis.kml.v_2_2_0.LineString) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Example 40 with Action

use of ddf.action.Action in project ddf by codice.

the class TestRegistryReportActionProvider method testBlankSourceId.

@Test
public void testBlankSourceId() {
    metacard.setSourceId("");
    configureActionProvider();
    Action action = actionProvider.getActions(metacard).get(0);
    assertThat(action.getUrl().toString(), is(SAMPLE_PROTOCOL + SAMPLE_IP + ":" + SAMPLE_PORT + SAMPLE_SERVICES_ROOT + SAMPLE_PATH + metacard.getAttribute(RegistryObjectMetacardType.REGISTRY_ID).getValue().toString() + PATH_AND_FORMAT));
}
Also used : Action(ddf.action.Action) Test(org.junit.Test)

Aggregations

Action (ddf.action.Action)44 Test (org.junit.Test)33 URL (java.net.URL)9 HashMap (java.util.HashMap)8 Metacard (ddf.catalog.data.Metacard)7 ActionProvider (ddf.action.ActionProvider)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ActionImpl (ddf.action.impl.ActionImpl)3 MultiActionProvider (ddf.action.MultiActionProvider)2 BinaryContent (ddf.catalog.data.BinaryContent)2 Result (ddf.catalog.data.Result)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2 ResultImpl (ddf.catalog.data.impl.ResultImpl)2 SourceResponse (ddf.catalog.operation.SourceResponse)2 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Date (java.util.Date)2