use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class SolrProviderCreate method testCreateNullList.
@Test
public void testCreateNullList() throws IngestException, UnsupportedQueryException {
deleteAll(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));
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class SolrProviderCreate method testCreatePendingNrtIndex.
@Test
public void testCreatePendingNrtIndex() throws Exception {
deleteAll(provider);
ConfigurationStore.getInstance().setForceAutoCommit(false);
try {
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
CreateResponse response = create(metacard, provider);
String createdId = response.getCreatedMetacards().get(0).getId();
Filter titleFilter = getFilterBuilder().attribute(Metacard.TITLE).like().text(MockMetacard.DEFAULT_TITLE);
Filter idFilter = getFilterBuilder().attribute(Metacard.ID).equalTo().text(createdId);
SourceResponse titleResponse = provider.query(new QueryRequestImpl(new QueryImpl(titleFilter)));
SourceResponse idResponse = provider.query(new QueryRequestImpl(new QueryImpl(idFilter)));
assertThat(titleResponse.getResults().size(), is(0));
assertThat(idResponse.getResults().size(), is(1));
} finally {
ConfigurationStore.getInstance().setForceAutoCommit(true);
}
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class SolrProviderDelete method testDeletePendingNrtIndex.
@Test
public void testDeletePendingNrtIndex() throws Exception {
deleteAll(provider);
ConfigurationStore.getInstance().setForceAutoCommit(false);
try {
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
CreateResponse createResponse = create(metacard, provider);
DeleteResponse deleteResponse = delete(createResponse.getCreatedMetacards().get(0).getId(), provider);
Metacard deletedMetacard = deleteResponse.getDeletedMetacards().get(0);
verifyDeletedRecord(metacard, createResponse, deleteResponse, deletedMetacard);
} finally {
ConfigurationStore.getInstance().setForceAutoCommit(true);
}
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class SolrProviderDelete method testDeleteAlternativeAttribute.
/**
* Testing if another attribute can be used to delete records other than {@link Metacard#ID}
*/
@Test
public void testDeleteAlternativeAttribute() throws IngestException, UnsupportedQueryException {
deleteAll(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
CreateResponse createResponse = create(metacard, provider);
DeleteResponse deleteResponse = provider.delete(new DeleteRequest() {
@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<? extends Serializable> getAttributeValues() {
return Collections.singletonList(MockMetacard.DEFAULT_TITLE);
}
@Override
public String getAttributeName() {
return Metacard.TITLE;
}
});
Metacard deletedMetacard = deleteResponse.getDeletedMetacards().get(0);
verifyDeletedRecord(metacard, createResponse, deleteResponse, deletedMetacard);
// verify it is really not in SOLR
Filter filter = getFilterBuilder().attribute(Metacard.TITLE).like().text(MockMetacard.DEFAULT_TITLE);
QueryImpl query = new QueryImpl(filter);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
List<Result> results = sourceResponse.getResults();
assertEquals(0, results.size());
}
use of ddf.catalog.operation.CreateResponse in project ddf by codice.
the class SolrProviderTest method testUpdateOperationSimple.
/**
* Testing that if records are properly updated.
*
* @throws IngestException
* @throws UnsupportedQueryException
*/
@Test
public void testUpdateOperationSimple() throws IngestException, UnsupportedQueryException {
// Single Update
deleteAllIn(provider);
MockMetacard metacard = new MockMetacard(Library.getFlagstaffRecord());
CreateResponse createResponse = create(metacard);
String id = createResponse.getCreatedMetacards().get(0).getId();
metacard.setContentTypeName("newContentType");
UpdateResponse response = update(id, metacard);
Update update = response.getUpdatedMetacards().get(0);
Metacard newMetacard = update.getNewMetacard();
Metacard oldMetacard = update.getOldMetacard();
assertEquals(1, response.getUpdatedMetacards().size());
assertEquals("newContentType", newMetacard.getContentTypeName());
assertEquals(MockMetacard.DEFAULT_TYPE, oldMetacard.getContentTypeName());
}
Aggregations