use of ddf.catalog.operation.UpdateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testMetacardFailsEnforcedValidatorNoDescribable.
@Test
public void testMetacardFailsEnforcedValidatorNoDescribable() throws ValidationException, StopProcessingException, PluginExecutionException {
MetacardValidator mockValidator = getMockFailingValidatorNoDescribable();
metacardValidators.add(mockValidator);
enforcedMetacardValidators.add(mockValidator.getClass().getCanonicalName());
CreateRequest createRequest = getMockCreateRequest();
List<Metacard> createdMetacards = createRequest.getMetacards();
verifyEnforcedCreate(createRequest, createdMetacards.subList(1, createdMetacards.size()));
UpdateRequest updateRequest = getMockUpdateRequest();
List<Metacard> updatedMetacards = getUpdatedMetacards(updateRequest);
verifyEnforcedUpdate(updateRequest, updatedMetacards.subList(1, updatedMetacards.size()));
}
use of ddf.catalog.operation.UpdateRequest in project ddf by codice.
the class RegistryStoreImpl method update.
@Override
public UpdateResponse update(UpdateRequest request) throws IngestException {
if (request.getUpdates().stream().map(e -> RegistryUtility.getRegistryId(e.getValue())).anyMatch(Objects::isNull)) {
throw new IngestException("One or more of the metacards is not a registry metacard");
}
Map<String, Metacard> updatedMetacards = request.getUpdates().stream().collect(Collectors.toMap(e -> RegistryUtility.getRegistryId(e.getValue()), Map.Entry::getValue));
Map<String, Metacard> origMetacards = ((OperationTransaction) request.getPropertyValue(Constants.OPERATION_TRANSACTION_KEY)).getPreviousStateMetacards().stream().collect(Collectors.toMap(RegistryUtility::getRegistryId, e -> e));
//update the new metacards with the id from the orig so that they can be found on the remote system
try {
for (Map.Entry<String, Metacard> entry : updatedMetacards.entrySet()) {
setMetacardExtID(entry.getValue(), origMetacards.get(entry.getKey()).getId());
}
} catch (ParserException e) {
throw new IngestException("Could not update metacards id", e);
}
return super.update(request);
}
use of ddf.catalog.operation.UpdateRequest in project ddf by codice.
the class PointOfContactUpdatePluginTest method processPreUpdateDoesNothingIfNewPOCHasAValue.
@Test
public void processPreUpdateDoesNothingIfNewPOCHasAValue() throws Exception {
listOfUpdatedMetacards.forEach(m -> m.setAttribute(new AttributeImpl(Metacard.POINT_OF_CONTACT, NEW_EMAIL)));
UpdateRequest updateRequestOutput = pointOfContactUpdatePlugin.processPreUpdate(updateRequestInput, existingMetacards);
assertThat(updateRequestOutput.getUpdates().get(0).getValue().getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(NEW_EMAIL));
assertThat(updateRequestOutput.getUpdates().get(1).getValue().getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(NEW_EMAIL));
assertThat(updateRequestOutput.getUpdates().get(2).getValue().getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(NEW_EMAIL));
}
use of ddf.catalog.operation.UpdateRequest in project ddf by codice.
the class PointOfContactUpdatePluginTest method processPreUpdateOnlyModifiesResourceMetacards.
@Test
public void processPreUpdateOnlyModifiesResourceMetacards() throws Exception {
UpdateRequest updateRequestOutput = pointOfContactUpdatePlugin.processPreUpdate(updateRequestInput, existingMetacards);
assertThat(updateRequestOutput.getUpdates().get(0).getValue().getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(ADMIN_EMAIL));
assertThat(updateRequestOutput.getUpdates().get(1).getValue().getAttribute(Metacard.POINT_OF_CONTACT).getValue(), equalTo(ADMIN_EMAIL));
assertThat(updateRequestOutput.getUpdates().get(2).getValue().getAttribute(Metacard.POINT_OF_CONTACT), is(nullValue()));
}
use of ddf.catalog.operation.UpdateRequest in project ddf by codice.
the class MetacardIngestNetworkPluginTest method testPassthroughMethods.
@Test
public void testPassthroughMethods() throws Exception {
ThreadContext.put(CLIENT_INFO_KEY, INFO_MAP);
when(mockMetacardCondition.applies(INFO_MAP)).thenReturn(true);
UpdateRequest updateRequest = mock(UpdateRequest.class);
DeleteRequest deleteRequest = mock(DeleteRequest.class);
QueryRequest queryRequest = mock(QueryRequest.class);
ResourceRequest resourceRequest = mock(ResourceRequest.class);
DeleteResponse deleteResponse = mock(DeleteResponse.class);
QueryResponse queryResponse = mock(QueryResponse.class);
ResourceResponse resourceResponse = mock(ResourceResponse.class);
assertThat(plugin.processPreUpdate(updateRequest, mock(Map.class)), is(updateRequest));
assertThat(plugin.processPreDelete(deleteRequest), is(deleteRequest));
assertThat(plugin.processPreQuery(queryRequest), is(queryRequest));
assertThat(plugin.processPreResource(resourceRequest), is(resourceRequest));
assertThat(plugin.processPostDelete(deleteResponse), is(deleteResponse));
assertThat(plugin.processPostQuery(queryResponse), is(queryResponse));
assertThat(plugin.processPostResource(resourceResponse, mock(Metacard.class)), is(resourceResponse));
verifyZeroInteractions(mockMetacardCondition, mockMetacardServices, updateRequest, deleteRequest, queryRequest, resourceRequest, deleteResponse, queryResponse, resourceResponse);
}
Aggregations