use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class MetacardValidityMarkerPluginTest method testMultipleValidationTagsInvalid.
@Test
public void testMultipleValidationTagsInvalid() throws StopProcessingException, PluginExecutionException, ValidationException {
metacardValidators.add(getMockFailingValidatorWithErrorsAndWarnings());
CreateRequest request = getMockCreateRequest();
Metacard m1 = request.getMetacards().get(0);
Set<String> tags = m1.getTags();
tags.add(VALID_TAG);
m1.setAttribute(AttributeImpl.fromMultipleValues(Metacard.TAGS, new ArrayList<>(tags)));
CreateRequest filteredRequest = plugin.process(request);
assertThat(filteredRequest.getMetacards().get(0).getTags(), hasItem(INVALID_TAG));
assertThat(filteredRequest.getMetacards().get(0).getTags(), not(hasItem(VALID_TAG)));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class MetacardIngestNetworkPluginTest method testClientInfoMapNull.
@Test
public void testClientInfoMapNull() throws Exception {
ThreadContext.put(CLIENT_INFO_KEY, null);
CreateRequest createRequest = plugin.processPreCreate(mockCreateRequest);
verifyZeroInteractions(mockMetacardServices, mockMetacardCondition);
assertThat(createRequest, is(mockCreateRequest));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class GeoNamesCatalogIndexer method executeCreateMetacardRequest.
private void executeCreateMetacardRequest(List<Metacard> metacards) {
int totalMetacards = metacards.size();
for (int i = 0; i < totalMetacards; i += BATCH_SIZE) {
int lastIndex = i + BATCH_SIZE;
if (lastIndex > metacards.size()) {
lastIndex = metacards.size();
}
List<Metacard> sublist = metacards.subList(i, lastIndex);
Map<String, Serializable> properties = new HashMap<>();
CreateRequest createRequest = new CreateRequestImpl(sublist, properties);
try {
CreateResponse createResponse = catalogFramework.create(createRequest);
List<Metacard> createdMetacards = createResponse.getCreatedMetacards();
LOGGER.trace("Created {} metacards.", createdMetacards == null ? 0 : createdMetacards.size());
} catch (IngestException | SourceUnavailableException e) {
LOGGER.debug("Unable to create Metacards", e);
}
}
LOGGER.trace("Created {} metacards.", totalMetacards);
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class GeoNamesCatalogIndexerTest method testUpdateIndexBatches.
@Test
public void testUpdateIndexBatches() throws Exception {
List<Metacard> metacardList = new ArrayList<>();
int totalExpectedEntries = 360;
for (int i = 0; i < totalExpectedEntries; i++) {
metacardList.add(METACARD);
}
ArgumentCaptor<CreateRequest> createRequestArgumentCaptor = ArgumentCaptor.forClass(CreateRequest.class);
when(createResponse.getCreatedMetacards()).thenReturn(metacardList);
geoNamesCatalogIndexer.updateIndex(LARGE_FILE_PATH, geoEntryExtractor, false, progressCallback);
verify(catalogFramework, times(2)).create(createRequestArgumentCaptor.capture());
List<CreateRequest> createRequestList = createRequestArgumentCaptor.getAllValues();
int totalEntries = 0;
for (CreateRequest createRequest : createRequestList) {
totalEntries += createRequest.getMetacards().size();
}
assertThat(totalEntries, is(totalExpectedEntries));
}
use of ddf.catalog.operation.CreateRequest in project ddf by codice.
the class CatalogFrameworkImplTest method testInjectsAttributesOnCreate.
@Test
public void testInjectsAttributesOnCreate() throws Exception {
final String title = "Create";
final String injectAttributeName = "new attribute";
final double injectAttributeValue = 2;
final MetacardImpl originalMetacard = new MetacardImpl();
originalMetacard.setTitle(title);
originalMetacard.setAttribute(injectAttributeName, injectAttributeValue);
final List<Metacard> metacards = Collections.singletonList(originalMetacard);
final CreateRequest request = new CreateRequestImpl(metacards, null);
final AttributeDescriptor injectAttribute = new AttributeDescriptorImpl(injectAttributeName, true, true, false, false, BasicTypes.DOUBLE_TYPE);
stubMetacardInjection(injectAttribute);
final CreateResponse response = framework.create(request);
final Metacard createdMetacard = response.getCreatedMetacards().get(0);
final MetacardType createdMetacardType = createdMetacard.getMetacardType();
final MetacardType originalMetacardType = originalMetacard.getMetacardType();
assertThat(createdMetacardType.getName(), is(originalMetacardType.getName()));
final Set<AttributeDescriptor> expectedAttributeDescriptors = new HashSet<>(originalMetacardType.getAttributeDescriptors());
expectedAttributeDescriptors.add(injectAttribute);
assertThat(createdMetacardType.getAttributeDescriptors(), is(expectedAttributeDescriptors));
assertThat(createdMetacard.getTitle(), is(title));
assertThat(createdMetacard.getAttribute(injectAttributeName).getValue(), is(injectAttributeValue));
}
Aggregations