本文整理汇总了Java中com.redhat.lightblue.crud.CRUDDeleteResponse类的典型用法代码示例。如果您正苦于以下问题:Java CRUDDeleteResponse类的具体用法?Java CRUDDeleteResponse怎么用?Java CRUDDeleteResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CRUDDeleteResponse类属于com.redhat.lightblue.crud包,在下文中一共展示了CRUDDeleteResponse类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteSingleBatch
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void deleteSingleBatch() {
// setup data to delete
String id = "deleteTest1";
DBObject obj = new BasicDBObject();
obj.put("_id", id);
obj.put("objectType", "test");
coll.insert(obj);
try (DBCursor c = coll.find(null)) {
Assert.assertEquals("count on collection", 1, c.count());
}
// execute delete
BasicDocDeleter deleter = new BasicDocDeleter(translator, null, batchSize);
deleter.hookOptimization=false;
DBObject mongoQuery = new BasicDBObject();
mongoQuery.put("_id", id);
CRUDDeleteResponse response = new CRUDDeleteResponse();
deleter.delete(ctx, spiedCollection, mongoQuery, response);
Assert.assertEquals("num deleted", 1, response.getNumDeleted());
// verify nothing left in collection
Assert.assertEquals("count on collection", 0, coll.find(null).count());
// the batch is called once
Mockito.verify(spiedCollection, Mockito.times(1)).initializeUnorderedBulkOperation();
}
示例2: deleteMultiBatch
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void deleteMultiBatch() {
int docsToInsertCount = batchSize+2;
// setup data to delete
for (int i=0;i<docsToInsertCount;i++) {
String id = "deleteTest1-"+i;
DBObject obj = new BasicDBObject();
obj.put("_id", id);
obj.put("objectType", "test");
coll.insert(obj);
}
try (DBCursor c = coll.find(null)) {
Assert.assertEquals("count on collection", docsToInsertCount, c.count());
}
// execute delete
BasicDocDeleter deleter = new BasicDocDeleter(translator, null, batchSize);
deleter.hookOptimization=false;
DBObject mongoQuery = new BasicDBObject();
mongoQuery.put("objectType", "test");
CRUDDeleteResponse response = new CRUDDeleteResponse();
deleter.delete(ctx, spiedCollection, mongoQuery, response);
Assert.assertEquals("num deleted", docsToInsertCount, response.getNumDeleted());
// verify nothing left in collection
Assert.assertEquals("count on collection", 0, coll.find(null).count());
// the batch is called twice
Mockito.verify(spiedCollection, Mockito.times(2)).initializeUnorderedBulkOperation();
}
示例3: deleteTest
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void deleteTest() throws Exception {
EntityMetadata md = getMd("./testMetadata.json");
TestCRUDOperationContext ctx = new TestCRUDOperationContext(CRUDOperation.INSERT);
ctx.add(md);
// Generate some docs
List<JsonDoc> docs = new ArrayList<>();
int numDocs = 20;
for (int i = 0; i < numDocs; i++) {
JsonDoc jsonDOc = new JsonDoc(loadJsonNode("./testdata1.json"));
jsonDOc.modify(new Path("field1"), nodeFactory.textNode("doc" + i), false);
jsonDOc.modify(new Path("field3"), nodeFactory.numberNode(i), false);
docs.add(jsonDOc);
}
addDocuments(ctx,docs);
controller.insert(ctx, projection("{'field':'_id'}"));
try (DBCursor c = coll.find(null)) {
Assert.assertEquals(numDocs, c.count());
}
// Single doc delete
ctx = new TestCRUDOperationContext(CRUDOperation.DELETE);
ctx.add(md);
CRUDDeleteResponse del = controller.delete(ctx, query("{'field':'field3','op':'$eq','rvalue':10}"));
Assert.assertEquals(1, del.getNumDeleted());
try (DBCursor c = coll.find(null)) {
Assert.assertEquals(numDocs - 1, c.count());
}
// Bulk delete
ctx = new TestCRUDOperationContext(CRUDOperation.DELETE);
ctx.add(md);
del = controller.delete(ctx, query("{'field':'field3','op':'>','rvalue':10}"));
Assert.assertEquals(9, del.getNumDeleted());
try (DBCursor c = coll.find(null)) {
Assert.assertEquals(10, c.count());
}
}
示例4: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx,
QueryExpression query) {
if (query == null) {
throw new IllegalArgumentException("No query was provided.");
}
CRUDDeleteResponse deleteResponse = new CRUDDeleteResponse();
deleteResponse.setNumDeleted(0);
EntityMetadata md = ctx.getEntityMetadata(ctx.getEntityName());
LdapDataStore store = LdapCrudUtil.getLdapDataStore(md);
SearchRequest searchRequest = buildSearchRequest(store.getBaseDN(), md, query, null, SearchRequest.NO_ATTRIBUTES);
LDAPConnection connection = getLdapConnection(store);
runSearch(connection, searchRequest, ctx,
(SearchResultEntry entry) -> {
//LDAP only supports performing 1 delete at a time.
execute(ctx, new ExecutionHandler() {
@Override
void onSuccess(LDAPResult deleteResult) {
deleteResponse.setNumDeleted(deleteResponse.getNumDeleted() + 1);
}
@Override
LDAPResult execute() throws LDAPException {
return connection.delete(entry.getDN());
}
});
});
return deleteResponse;
}
示例5: deleteRoleTest
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void deleteRoleTest() throws Exception {
DeleteRequest req = new DeleteRequest();
req.setEntityVersion(new EntityVersion("test", "1.0"));
mdManager.md.getAccess().getDelete().setRoles("role1");
mockCrudController.deleteResponse = new CRUDDeleteResponse();
Response response = mediator.delete(req);
Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
Assert.assertEquals(0, response.getModifiedCount());
Assert.assertEquals(0, response.getMatchCount());
Assert.assertEquals(0, response.getDataErrors().size());
Assert.assertEquals(1, response.getErrors().size());
Assert.assertEquals(CrudConstants.ERR_NO_ACCESS, response.getErrors().get(0).getErrorCode());
mdManager.md.getAccess().getDelete().setRoles("anyone");
mockCrudController.deleteResponse.setNumDeleted(1);
response = mediator.delete(req);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
Assert.assertEquals(1, response.getModifiedCount());
Assert.assertEquals(0, response.getMatchCount());
Assert.assertEquals(0, response.getDataErrors().size());
Assert.assertEquals(0, response.getErrors().size());
// Response should return the entity name:version
Assert.assertEquals("test",response.getEntity().getEntity());
Assert.assertEquals("1.0",response.getEntity().getVersion());
}
示例6: deleteQueryFieldRoleTest
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void deleteQueryFieldRoleTest() throws Exception {
DeleteRequest req = new DeleteRequest();
req.setEntityVersion(new EntityVersion("test", "1.0"));
req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
req.setClientId(new RestClientIdentification(Arrays.asList("test-delete")));
mockCrudController.deleteResponse = new CRUDDeleteResponse();
Response response = mediator.delete(req);
Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
response = mediator.delete(req);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
示例7: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx,
QueryExpression query) {
updateQuery = query;
return new CRUDDeleteResponse();
}
示例8: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx,
QueryExpression query) {
return null;
}
示例9: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx, QueryExpression query) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
示例10: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx,
QueryExpression query) {
deleteCb.cb(ctx);
return deleteResponse;
}
示例11: tracksMetricsForRequestsInsideBulkRequest
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Test
public void tracksMetricsForRequestsInsideBulkRequest() throws Exception {
MetricRegistry metricsRegistry = new MetricRegistry();
DropwizardRequestMetrics.MetricNamer metricNamer = new DefaultMetricNamer();
RequestMetrics metrics = new DropwizardRequestMetrics(metricsRegistry, metricNamer);
BulkRequest breq = new BulkRequest();
InsertionRequest ireq = new InsertionRequest();
ireq.setEntityVersion(new EntityVersion("user", "1.0"));
ireq.setEntityData(loadJsonNode("./sample1.json"));
ireq.setReturnFields(null);
ireq.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
breq.add(ireq);
FindRequest freq = new FindRequest();
freq.setEntityVersion(new EntityVersion("country", "2.0"));
breq.add(freq);
mockCrudController.insertResponse=new CRUDInsertionResponse();
mockCrudController.insertResponse.setNumInserted(1);
DeleteRequest dreq = new DeleteRequest();
dreq.setEntityVersion(new EntityVersion("test", "3.0"));
breq.add(dreq);
mockCrudController.deleteResponse=new CRUDDeleteResponse();
mockCrudController.deleteResponse.setNumDeleted(1);
BulkResponse bresp = mediator.bulkRequest(breq, metrics);
Response response = bresp.getEntries().get(0);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
Assert.assertEquals(1, response.getModifiedCount());
RequestMetric insertUser = metricNamer.crud("insert", "user", "1.0");
Assert.assertEquals(1, insertUser.requestTimer(metricsRegistry).getCount());
response = bresp.getEntries().get(1);
RequestMetric findCountry = metricNamer.crud("find", "country", "2.0");
Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
Assert.assertEquals(1, response.getErrors().size());
Assert.assertEquals(CrudConstants.ERR_NO_ACCESS, response.getErrors().get(0).getErrorCode());
Assert.assertEquals(1, findCountry.requestTimer(metricsRegistry).getCount());
Assert.assertEquals(1, findCountry.errorMeter(metricsRegistry, CrudConstants.ERR_NO_ACCESS).getCount());
response = bresp.getEntries().get(2);
RequestMetric deleteTest = metricNamer.crud("delete", "test", "3.0");
Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
Assert.assertEquals(1, response.getErrors().size());
Assert.assertEquals(CrudConstants.ERR_NO_ACCESS, response.getErrors().get(0).getErrorCode());
Assert.assertEquals(1, deleteTest.requestTimer(metricsRegistry).getCount());
Assert.assertEquals(1, deleteTest.errorMeter(metricsRegistry, CrudConstants.ERR_NO_ACCESS).getCount());
}
示例12: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
@Override
public CRUDDeleteResponse delete(CRUDOperationContext ctx,
QueryExpression query) {
return new CRUDDeleteResponse();
}
示例13: delete
import com.redhat.lightblue.crud.CRUDDeleteResponse; //导入依赖的package包/类
/**
* Delete documents
*
* @param ctx Operation context
* @param collection The collection from which the documents will be deleted
* @param mongoQuery The query whose result set will be deleted
* @param response The deletion response
*
* The implementation should delete the documents, and update the response
* with the number of docs deleted. No exception handling is expected from
* the implementation, so all unhandled exceptions should be rethrown.
*/
void delete(CRUDOperationContext ctx,
DBCollection collection,
DBObject mongoQuery,
CRUDDeleteResponse response);