use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class PluginTest method testCreate.
@Test
@Ignore
public void testCreate() throws PluginExecutionException, CatalogTransformerException, IOException, IngestException, SourceUnavailableException {
// given
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
CreateResponse response = plugin.process(createResponse);
// then
verify(endpoint).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
assertThat(response, sameInstance(createResponse));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class PluginTest method testCreateNullParent.
@Test
@Ignore
public void testCreateNullParent() throws PluginExecutionException, IngestException, SourceUnavailableException {
// given
CreateResponse createResponse = new CreateResponseImpl(new CreateRequestImpl(metacard), null, Arrays.asList(metacard));
// when
plugin.process(createResponse);
// then
verify(endpoint, never()).addDocument(isA(HttpHeaders.class), isA(UriInfo.class), isA(InputStream.class));
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testPreExistingMetacardErrorsAndWarningsNoDuplicates.
@Test
public void testPreExistingMetacardErrorsAndWarningsNoDuplicates() throws ValidationException, StopProcessingException, PluginExecutionException {
metacardValidators.add(getMockFailingValidatorWithErrorsAndWarnings());
CreateRequestImpl request = new CreateRequestImpl(metacardsWithPreExistingAttributes(true, true), PROPERTIES, DESTINATIONS);
verifyCreate(request, expectError, expectWarning, INVALID_TAG);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testPreExistingMetacardWarnings.
@Test
public void testPreExistingMetacardWarnings() throws ValidationException, StopProcessingException, PluginExecutionException {
metacardValidators.add(getMockPassingValidator());
CreateRequestImpl request = new CreateRequestImpl(metacardsWithPreExistingAttributes(false, true), PROPERTIES, DESTINATIONS);
verifyCreate(request, expectNone, expectWarning, INVALID_TAG);
}
use of ddf.catalog.operation.impl.CreateRequestImpl in project ddf by codice.
the class CatalogFrameworkImplTest method testInjectsAttributesOnUpdate.
@Test
public void testInjectsAttributesOnUpdate() throws Exception {
final String injectAttributeName = "new attribute";
final AttributeDescriptor injectAttribute = new AttributeDescriptorImpl(injectAttributeName, true, true, false, false, BasicTypes.DOUBLE_TYPE);
stubMetacardInjection(injectAttribute);
final String id = framework.create(new CreateRequestImpl(Collections.singletonList(new MetacardImpl()), null)).getCreatedMetacards().get(0).getId();
final String title = "Update";
final double injectAttributeValue = -1;
final MetacardImpl metacard = new MetacardImpl();
metacard.setId(id);
metacard.setTitle(title);
metacard.setAttribute(injectAttributeName, injectAttributeValue);
final UpdateRequest request = new UpdateRequestImpl(id, metacard);
List<Result> mockFederationResults = Stream.of(metacard).map(m -> {
Result mockResult = mock(Result.class);
when(mockResult.getMetacard()).thenReturn(m);
return mockResult;
}).collect(Collectors.toList());
QueryResponseImpl queryResponse = new QueryResponseImpl(mock(QueryRequest.class), mockFederationResults, 1);
when(mockFederationStrategy.federate(anyList(), any())).thenReturn(queryResponse);
final UpdateResponse response = framework.update(request);
final Metacard updatedMetacard = response.getUpdatedMetacards().get(0).getNewMetacard();
final MetacardType originalMetacardType = metacard.getMetacardType();
final MetacardType updatedMetacardType = updatedMetacard.getMetacardType();
assertThat(updatedMetacardType.getName(), is(originalMetacardType.getName()));
final Set<AttributeDescriptor> expectedAttributeDescriptors = new HashSet<>(originalMetacardType.getAttributeDescriptors());
expectedAttributeDescriptors.add(injectAttribute);
assertThat(updatedMetacardType.getAttributeDescriptors(), is(expectedAttributeDescriptors));
assertThat(updatedMetacard.getTitle(), is(title));
assertThat(updatedMetacard.getAttribute(injectAttributeName).getValue(), is(injectAttributeValue));
}
Aggregations