Search in sources :

Example 66 with CreateRequest

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

the class CatalogMetricsTest method catalogCreateExceptionMetric.

@Test
public void catalogCreateExceptionMetric() throws Exception {
    Iterable<Tag> createExceptionTags = Tags.of("type", IngestException.class.getName(), "source", "source2");
    CreateRequest request = mock(CreateRequest.class);
    CreateResponse response = mock(CreateResponse.class);
    mockCatalogResponseExceptions(request, response, new ProcessingDetailsImpl("source2", new IngestException()));
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.create.exceptions", createExceptionTags).count(), is(1.0));
}
Also used : CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) IngestException(ddf.catalog.source.IngestException) Tag(io.micrometer.core.instrument.Tag) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 67 with CreateRequest

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

the class CatalogMetricsTest method catalogCreateMetric.

@Test
public void catalogCreateMetric() throws Exception {
    CreateRequest request = mock(CreateRequest.class);
    CreateResponse response = mock(CreateResponse.class);
    List<Metacard> createdList = mock(List.class);
    when(createdList.size()).thenReturn(100);
    when(response.getRequest()).thenReturn(request);
    when(response.getCreatedMetacards()).thenReturn(createdList);
    catalogMetrics.process(response);
    assertThat(meterRegistry.counter("ddf.catalog.create").count(), is(100.0));
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) Test(org.junit.Test)

Example 68 with CreateRequest

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

the class MetacardValidityMarkerPluginTest method testMetacardPassesEnforcedValidators.

@Test
public void testMetacardPassesEnforcedValidators() throws StopProcessingException, PluginExecutionException {
    metacardValidators.add(getMockEnforcedPassingValidatorWithId(ID));
    enforcedMetacardValidators.add(ID);
    CreateRequest createRequest = getMockCreateRequest();
    List<Metacard> createdMetacards = createRequest.getMetacards();
    verifyEnforcedCreate(createRequest, createdMetacards);
    UpdateRequest updateRequest = getMockUpdateRequest();
    List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
    verifyEnforcedUpdate(updateRequest, updatedMetacards);
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) CreateRequest(ddf.catalog.operation.CreateRequest) Test(org.junit.Test)

Example 69 with CreateRequest

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

the class MetacardValidityMarkerPluginTest method verifyEnforcedCreate.

private void verifyEnforcedCreate(CreateRequest originalRequest, List<Metacard> expectedAllowedMetacards) throws PluginExecutionException, StopProcessingException {
    CreateRequest filteredRequest = plugin.process(originalRequest);
    List<Metacard> filteredMetacards = filteredRequest.getMetacards();
    verifyAllowedMetacards(filteredMetacards, expectedAllowedMetacards);
    verifyRequestPropertiesUnchanged(originalRequest, filteredRequest);
}
Also used : Metacard(ddf.catalog.data.Metacard) CreateRequest(ddf.catalog.operation.CreateRequest)

Example 70 with CreateRequest

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

the class MetacardValidityMarkerPluginTest method testMetacardPassesEnforcedValidatorsNoDescribable.

@Test
public void testMetacardPassesEnforcedValidatorsNoDescribable() throws StopProcessingException, PluginExecutionException {
    MetacardValidator mockValidator = getMockPassingValidatorNoDescribable();
    metacardValidators.add(mockValidator);
    enforcedMetacardValidators.add(mockValidator.getClass().getCanonicalName());
    CreateRequest createRequest = getMockCreateRequest();
    List<Metacard> createdMetacards = createRequest.getMetacards();
    verifyEnforcedCreate(createRequest, createdMetacards);
    UpdateRequest updateRequest = getMockUpdateRequest();
    List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
    verifyEnforcedUpdate(updateRequest, updatedMetacards);
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardValidator(ddf.catalog.validation.MetacardValidator) UpdateRequest(ddf.catalog.operation.UpdateRequest) CreateRequest(ddf.catalog.operation.CreateRequest) 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