use of ddf.action.Action in project ddf by codice.
the class DerivedContentActionProviderTest method testGetActionsNonContentUriWithQualifier.
@Test
public void testGetActionsNonContentUriWithQualifier() throws Exception {
ActionImpl expectedAction = new ActionImpl("expected", "expected", "expected", actionUri.toURL());
when(mockResourceActionProvider.getAction(any(Metacard.class))).thenReturn(expectedAction);
when(attribute.getValues()).thenReturn(Arrays.asList(actionUri));
List<Action> actions = actionProvider.getActions(metacard);
assertThat(actions, hasSize(1));
assertThat(actions.get(0), notNullValue());
assertThat(actions.get(0).getUrl(), notNullValue());
assertThat(actions.get(0).getUrl().toString(), is(actionUri.toString()));
assertThat(actions.get(0).getTitle(), is("View " + QUALIFIER_VALUE));
}
use of ddf.action.Action in project ddf by codice.
the class AtomTransformer method addLink.
// a Link object could not be made and returned without a classpath problem in the OSGi runtime
// therefore this was a workaround that did not require me to add special logic for
// contextclassloader
private void addLink(ActionProvider actionProvider, Metacard metacard, Entry entry, String linkType) {
if (actionProvider != null) {
try {
Action action = actionProvider.getAction(metacard);
if (action != null) {
if (actionProvider.equals(resourceActionProvider) && metacard.getResourceURI() != null) {
Link viewLink = addLinkHelper(action, entry, linkType, MIME_TYPE_OCTET_STREAM);
try {
Long length = Long.parseLong(metacard.getResourceSize(), 10);
viewLink.setLength(length);
} catch (NumberFormatException e) {
LOGGER.debug("Could not cast {} as Long type.", metacard.getResourceSize());
}
} else if (actionProvider.equals(thumbnailActionProvider) && metacard.getThumbnail() != null) {
addLinkHelper(action, entry, linkType, MIME_TYPE_JPEG);
} else if (!actionProvider.equals(resourceActionProvider) && !actionProvider.equals(thumbnailActionProvider)) {
addLinkHelper(action, entry, linkType, MIME_TYPE_OCTET_STREAM);
}
}
} catch (RuntimeException e) {
// ActionProvider is injected but not available
LOGGER.debug("Could not retrieve action.", e);
}
}
}
use of ddf.action.Action in project ddf by codice.
the class IdpLogoutActionProviderTest method testGetAction.
@Test
public void testGetAction() throws Exception {
Subject subject = mock(Subject.class);
HashMap map = new HashMap();
map.put("idp", subject);
Action action = idpLogoutActionProvider.getAction(map);
Assert.assertTrue("Expected the encrypted nameId and time", action.getUrl().getQuery().contains(nameIdTime));
}
use of ddf.action.Action in project ddf by codice.
the class IdpLogoutActionProviderTest method testGetActionFailure.
@Test
public void testGetActionFailure() throws Exception {
Object notsubject = new Object();
HashMap map = new HashMap();
map.put("idp", notsubject);
when(encryptionService.encrypt(any(String.class))).thenReturn(nameIdTime);
Action action = idpLogoutActionProvider.getAction(map);
Assert.assertNull("Expected the url to be null", action.getUrl());
}
Aggregations