Search in sources :

Example 6 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class ReplicateCommandTest method testFailedtoIngestHalf.

@Test
public void testFailedtoIngestHalf() throws Exception {
    when(catalogFramework.create(isA(CreateRequest.class))).thenAnswer(invocation -> {
        Object[] args = invocation.getArguments();
        CreateRequest request = (CreateRequest) args[0];
        when(mockCreateResponse.getCreatedMetacards()).thenReturn(request.getMetacards().subList(0, request.getMetacards().size() / 2));
        return mockCreateResponse;
    });
    replicateCommand.isUseTemporal = false;
    replicateCommand.sourceId = "sourceId1";
    replicateCommand.temporalProperty = Metacard.EFFECTIVE;
    replicateCommand.executeWithSubject();
    verifyReplicate(HITS, Metacard.EFFECTIVE);
    verifyConsoleOutput((int) Math.floor(HITS / 2) + " record(s) replicated; " + (int) (HITS - Math.floor(HITS / 2)) + " record(s) failed;");
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 7 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class TestMetacardGroomerPlugin method testCreateWithNoRecords.

@Test
public void testCreateWithNoRecords() throws PluginExecutionException, StopProcessingException {
    CreateRequest request = mock(CreateRequest.class);
    when(request.getMetacards()).thenReturn(new ArrayList<>());
    CreateRequest returnedRequest = plugin.process(request);
    assertThat(returnedRequest, not(nullValue()));
    assertThat(returnedRequest.getMetacards(), not(nullValue()));
    assertThat(returnedRequest.getMetacards().size(), is(0));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 8 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class TestMetacardGroomerPlugin method testCreateWithNullRequest.

@Test
public void testCreateWithNullRequest() throws PluginExecutionException, StopProcessingException {
    CreateRequest returnedRequest = plugin.process((CreateRequest) null);
    assertThat(returnedRequest, nullValue());
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 9 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class TestMetacardGroomerPlugin method processCreate.

private Metacard processCreate(Metacard inputMetacard) throws PluginExecutionException, StopProcessingException {
    CreateRequestImpl inputRequest = new CreateRequestImpl(copy(inputMetacard));
    CreateRequest returnedRequest = plugin.process(inputRequest);
    assertNotNull(returnedRequest);
    assertThat(returnedRequest.getMetacards().size(), is(1));
    return returnedRequest.getMetacards().get(0);
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl)

Example 10 with CreateRequest

use of ddf.catalog.operation.CreateRequest in project ddf by codice.

the class SolrProviderTest method testCreateNullList.

@Test
public void testCreateNullList() throws IngestException, UnsupportedQueryException {
    deleteAllIn(provider);
    CreateResponse response = provider.create(new CreateRequest() {

        @Override
        public boolean hasProperties() {
            return false;
        }

        @Override
        public Serializable getPropertyValue(String name) {
            return null;
        }

        @Override
        public Set<String> getPropertyNames() {
            return null;
        }

        @Override
        public Map<String, Serializable> getProperties() {
            return null;
        }

        @Override
        public boolean containsPropertyName(String name) {
            return false;
        }

        @Override
        public List<Metacard> getMetacards() {
            return null;
        }
    });
    assertThat(response.getCreatedMetacards().size(), is(0));
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequest(ddf.catalog.operation.CreateRequest) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Matchers.containsString(org.hamcrest.Matchers.containsString) Map(java.util.Map) Test(org.junit.Test)

Aggregations

CreateRequest (ddf.catalog.operation.CreateRequest)63 Test (org.junit.Test)49 Metacard (ddf.catalog.data.Metacard)38 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)36 CreateResponse (ddf.catalog.operation.CreateResponse)26 ArrayList (java.util.ArrayList)16 HashMap (java.util.HashMap)16 CreateResponseImpl (ddf.catalog.operation.impl.CreateResponseImpl)12 Subject (ddf.security.Subject)12 Serializable (java.io.Serializable)10 IngestException (ddf.catalog.source.IngestException)9 List (java.util.List)9 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)8 HashSet (java.util.HashSet)7 UpdateRequest (ddf.catalog.operation.UpdateRequest)6 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)6 IOException (java.io.IOException)6 InputStream (java.io.InputStream)6 CatalogFramework (ddf.catalog.CatalogFramework)4 QueryRequest (ddf.catalog.operation.QueryRequest)4