Search in sources :

Example 76 with CreateRequest

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);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 77 with CreateRequest

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()));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) Subject(ddf.security.Subject) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 78 with CreateRequest

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())));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) SubjectIdentity(ddf.security.SubjectIdentity) Subject(ddf.security.Subject) Test(org.junit.Test)

Example 79 with CreateRequest

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)));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) Subject(ddf.security.Subject) Test(org.junit.Test)

Example 80 with CreateRequest

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));
}
Also used : UpdateResponse(ddf.catalog.operation.UpdateResponse) DeletedMetacard(ddf.catalog.core.versioning.DeletedMetacard) Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) Update(ddf.catalog.operation.Update) Test(org.junit.Test)

Aggregations

CreateRequest (ddf.catalog.operation.CreateRequest)80 Test (org.junit.Test)62 Metacard (ddf.catalog.data.Metacard)44 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)39 CreateResponse (ddf.catalog.operation.CreateResponse)29 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)17 Subject (ddf.security.Subject)14 Serializable (java.io.Serializable)12 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)11 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)11 IngestException (ddf.catalog.source.IngestException)11 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)9 List (java.util.List)9 HashSet (java.util.HashSet)7 UpdateRequest (ddf.catalog.operation.UpdateRequest)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 Map (java.util.Map)5 CatalogFramework (ddf.catalog.CatalogFramework)4