use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class FanoutCatalogFrameworkTest method testBlacklistedTagCreateRequestFails.
@Test(expected = IngestException.class)
public void testBlacklistedTagCreateRequestFails() throws Exception {
Metacard metacard = new MetacardImpl();
metacard.setAttribute(new AttributeImpl(Metacard.TAGS, "blacklisted"));
CreateRequest request = new CreateRequestImpl(metacard);
framework.setFanoutTagBlacklist(Collections.singletonList("blacklisted"));
framework.create(request);
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class SecurityPluginTest method testNominalCaseCreateWithNonResourceMetacard.
@Test
public void testNominalCaseCreateWithNonResourceMetacard() throws Exception {
Subject mockSubject = setupMockSubject();
ThreadContext.bind(mockSubject);
MetacardImpl metacardWithTags = new MetacardImpl();
Set<String> setOfTags = new HashSet<String>();
setOfTags.add("workspace");
metacardWithTags.setTags(setOfTags);
CreateRequest request = new CreateRequestImpl(metacardWithTags);
SecurityPlugin plugin = new SecurityPlugin(subjectIdentity);
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
assertThat(request.getMetacards().size(), is(1));
assertThat(request.getMetacards().get(0).getAttribute(Metacard.POINT_OF_CONTACT), is(nullValue()));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class SecurityPluginTest method testNominalCaseCreateWithoutId.
@Test
public void testNominalCaseCreateWithoutId() throws Exception {
Subject mockSubject = mock(Subject.class);
ThreadContext.bind(mockSubject);
CreateRequest request = new MockCreateRequest();
SubjectIdentity noId = mock(SubjectIdentity.class);
when(noId.getUniqueIdentifier(any())).thenReturn(null);
SecurityPlugin plugin = new SecurityPlugin(noId);
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
assertThat(request.getMetacards().size(), is(2));
request.getMetacards().forEach(metacard -> assertThat(metacard.getAttribute(Metacard.POINT_OF_CONTACT), is(nullValue())));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class SecurityPluginTest method testNominalCaseCreateWithEmailAndNoTags.
@Test
public void testNominalCaseCreateWithEmailAndNoTags() throws Exception {
Subject mockSubject = setupMockSubject();
ThreadContext.bind(mockSubject);
CreateRequest request = new MockCreateRequest();
SecurityPlugin plugin = new SecurityPlugin(subjectIdentity);
request = plugin.processPreCreate(request);
assertThat(request.getPropertyValue(SecurityConstants.SECURITY_SUBJECT), equalTo(mockSubject));
assertThat(request.getMetacards().size(), is(2));
request.getMetacards().forEach(metacard -> assertThat(metacard.getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(TEST_USER)));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class HistorianTest method testUpdateResponse.
@Test
public void testUpdateResponse() throws Exception {
UpdateResponse updateResponse = createUpdateResponse(null);
List<Update> updateList = createUpdatedMetacardList();
when(updateResponse.getUpdatedMetacards()).thenReturn(updateList);
historian.version(updateResponse);
ArgumentCaptor<CreateRequest> createRequest = ArgumentCaptor.forClass(CreateRequest.class);
verify(catalogProvider).create(createRequest.capture());
Metacard versionedMetacard = createRequest.getValue().getMetacards().get(0);
assertThat(versionedMetacard.getAttribute(MetacardVersion.VERSION_OF_ID).getValue(), equalTo(METACARD_ID));
}
Aggregations