本文整理汇总了Java中com.redhat.lightblue.crud.FindRequest类的典型用法代码示例。如果您正苦于以下问题:Java FindRequest类的具体用法?Java FindRequest怎么用?Java FindRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FindRequest类属于com.redhat.lightblue.crud包,在下文中一共展示了FindRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyEvent
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
protected void verifyEvent(int expectedEvents, String query, String expectedIdentityFields, String expectedFields, String operation) throws Exception {
FindRequest findRequest = createRequest_FromJsonString(FindRequest.class, "{\"entity\":\"esbEvents\",\"entityVersion\":\"" + ESB_EVENTS_VERSION + "\"," + "\"query\":"
+ query + "," + "\"projection\": [{\"field\":\"*\",\"include\":true,\"recursive\":true}]}");
findRequest.setClientId(new FakeClientIdentification("FakeUser"));
Response findResponse = getLightblueFactory().getMediator().find(findRequest);
assertNoErrors(findResponse);
assertNoDataErrors(findResponse);
assertEquals(expectedEvents, findResponse.getMatchCount());
// dates and uids had to be left out to prevent test from always
// failing.
if (expectedEvents > 0) {
JSONAssert.assertEquals("[{\"identity\":" + expectedIdentityFields
+ ",\"esbRootEntityName\":\"Country\",\"esbEventEntityName\":\"State\",\"endSystem\":\"nameOfTargetSystem\",\"createdBy\":\"publishHook\",\"version\":\"0.1.0-SNAPSHOT\""
+ ",\"status\":\"UNPROCESSED\",\"lastUpdatedBy\":\"publishHook\",\"operation\":\"" + operation + "\","
+ "\"entityName\":\"country\",\"objectType\":\"esbEvents\"" + expectedFields + "}]", findResponse.getEntityData().toString(), false);
}
}
示例2: buildSimpleRequest
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
public static FindRequest buildSimpleRequest(String entity, String version, String q, String p, String s, Long from, Long to, Long maxResults)
throws IOException {
// spec -> https://github.com/lightblue-platform/lightblue/wiki/Rest-Spec-Data#get-simple-find
String sq = QueryTemplateUtils.buildQueryFieldsTemplate(q);
LOGGER.debug("query: {} -> {}", q, sq);
String sp = QueryTemplateUtils.buildProjectionsTemplate(p);
LOGGER.debug("projection: {} -> {}", p, sp);
String ss = QueryTemplateUtils.buildSortsTemplate(s);
LOGGER.debug("sort:{} -> {}", s, ss);
FindRequest findRequest = new FindRequest();
findRequest.setEntityVersion(new EntityVersion(entity, version));
findRequest.setQuery(sq == null ? null : QueryExpression.fromJson(JsonUtils.json(sq)));
findRequest.setProjection(sp == null ? null : Projection.fromJson(JsonUtils.json(sp)));
findRequest.setSort(ss == null ? null : Sort.fromJson(JsonUtils.json(ss)));
findRequest.setFrom(from);
if(to!=null) {
findRequest.setTo(to);
} else if(maxResults!=null&&maxResults>0) {
findRequest.setTo((from == null ? 0 : from) + maxResults - 1);
}
return findRequest;
}
示例3: getSearchesForEntity
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@GET
@LZF
@Path("/search/{entity}")
public Response getSearchesForEntity(@PathParam("entity") String entity,
@QueryParam("P") String projection,
@QueryParam("S") String sort) {
FindRequest freq=new FindRequest();
freq.setEntityVersion(new EntityVersion(RestConfiguration.getSavedSearchCache().savedSearchEntity,
RestConfiguration.getSavedSearchCache().savedSearchVersion));
try {
freq.setProjection(projection==null?FieldProjection.ALL:Projection.fromJson(JsonUtils.json(QueryTemplateUtils.buildProjectionsTemplate(projection))));
freq.setSort(sort==null?new SortKey(new com.redhat.lightblue.util.Path("name"),false):Sort.fromJson(JsonUtils.json(QueryTemplateUtils.buildSortsTemplate(sort))));
} catch (Exception e) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString()).build();
}
CallStatus st=new FindCommand(freq.getEntityVersion().getEntity(),
freq.getEntityVersion().getVersion(),
freq.toJson().toString(), METRICS).run();
return Response.status(st.getHttpStatus()).entity(st.toString()).build();
}
示例4: buildSimpleRequest
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
private FindRequest buildSimpleRequest(String entity,String version, String q,String p, String s, Long from, Long to,Long maxResults)
throws IOException {
// spec -> https://github.com/lightblue-platform/lightblue/wiki/Rest-Spec-Data#get-simple-find
String sq = QueryTemplateUtils.buildQueryFieldsTemplate(q);
LOGGER.debug("query: {} -> {}", q, sq);
String sp = QueryTemplateUtils.buildProjectionsTemplate(p);
LOGGER.debug("projection: {} -> {}", p, sp);
String ss = QueryTemplateUtils.buildSortsTemplate(s);
LOGGER.debug("sort:{} -> {}", s, ss);
FindRequest findRequest = new FindRequest();
findRequest.setEntityVersion(new EntityVersion(entity, version));
findRequest.setQuery(sq == null ? null : QueryExpression.fromJson(JsonUtils.json(sq)));
findRequest.setProjection(sp == null ? null : Projection.fromJson(JsonUtils.json(sp)));
findRequest.setSort(ss == null ? null : Sort.fromJson(JsonUtils.json(ss)));
findRequest.setFrom(from);
if(to!=null) {
findRequest.setTo(to);
} else if(maxResults!=null&&maxResults>0) {
findRequest.setTo((from == null ? 0 : from) + maxResults - 1);
}
return findRequest;
}
示例5: test2FindCustomerWithProperties
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void test2FindCustomerWithProperties() throws Exception {
Response response = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/customer-find-single.json"));
assertNotNull(response);
assertNoErrors(response);
assertNoDataErrors(response);
assertEquals(1, response.getMatchCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{\"id\":\"uid=frodo.baggins," + BASEDB_CUSTOMERS + "\","
+ "\"customerId\":\"frodo.baggins\","
+ "\"firstName\":\"Frodo\","
+ "\"lastName\":\"Baggins\","
+ "\"cn\":\"Frodo Baggins\","
+ "\"interfaces#\":4,"
+ "\"interfaces\":[\"top\",\"person\",\"organizationalPerson\",\"inetOrgPerson\"]}]",
entityData.toString(), true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:23,代码来源:ITCaseLdapCRUDController_WithProperties_Test.java
示例6: assertPersonEntryValues
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
protected void assertPersonEntryValues(String uid, String cn, String optional) throws Exception {
Response findResponse = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/person-find-single.json"));
assertValidResponse(findResponse);
assertEquals(1, findResponse.getMatchCount());
JSONAssert.assertEquals(
"[{"
+ generatePersonDnJson(uid) + ","
+ "\"uid\":\"" + uid + "\","
+ "\"cn\":\"" + cn + "\","
+ "\"objectType\":\"person\","
+ "\"objectClass#\":4,"
+ "\"optional\":" + ((optional == null) ? "null" : "\"" + optional + "\"")
+ "}]",
findResponse.getEntityData().toString(), true);
}
示例7: testDelete
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void testDelete() throws Exception {
//Setup
assertValidResponse(getLightblueFactory().getMediator().insert(
createRequest_FromResource(InsertionRequest.class, "./crud/insert/person-insert-many.json")));
//Test
Response response = getLightblueFactory().getMediator().delete(
createRequest_FromResource(DeleteRequest.class, "./crud/delete/person-delete-simple.json"));
assertValidResponse(response);
assertEquals(1, response.getModifiedCount());
//Ensure entry was deleted
Response findResponse = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/person-find-many.json"));
assertValidResponse(findResponse);
//There were 3, now only 2
assertEquals(2, findResponse.getMatchCount());
}
示例8: testFindMany
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void testFindMany() throws Exception {
//Setup
assertValidResponse(getLightblueFactory().getMediator().insert(
createRequest_FromResource(InsertionRequest.class, "./crud/insert/person-insert-many.json")));
//Test
Response response = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/person-find-many.json"));
assertValidResponse(response);
assertEquals(3, response.getMatchCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
//Search requests results in desc order, strict mode is enforced to assure this.
JSONAssert.assertEquals(
"["
+ "{" + generatePersonDnJson("junior.doe") + "},"
+ "{" + generatePersonDnJson("john.doe") + "},"
+ "{" + generatePersonDnJson("jane.doe") + "}"
+ "]",
entityData.toString(), true);
}
示例9: testFindMany_WithPagination
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void testFindMany_WithPagination() throws Exception {
//Setup
assertValidResponse(getLightblueFactory().getMediator().insert(
createRequest_FromResource(InsertionRequest.class, "./crud/insert/person-insert-many.json")));
//Test
Response response = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/person-find-many-paginated.json"));
assertValidResponse(response);
assertEquals(1, response.getMatchCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{" + generatePersonDnJson("john.doe") + "}]",
entityData.toString(), true);
}
示例10: test2PersonWithAddress_Find
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void test2PersonWithAddress_Find() throws Exception {
Response response = getLightblueFactory().getMediator().find(
createRequest_FromResource(FindRequest.class, "./crud/find/person-with-address-find-single.json"));
assertNotNull(response);
assertNoErrors(response);
assertNoDataErrors(response);
assertEquals(1, response.getMatchCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{\"dn\":\"uid=john.doe," + BASEDB_USERS + "\",\"address\":{\"street\":\"123 Some St.\",\"postalCode\":12345,\"state\":\"NC\"}}]",
entityData.toString(), true);
}
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:17,代码来源:ITCaseLdapCRUDController_Objects_Test.java
示例11: test2UpdateCreatesAudits
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void test2UpdateCreatesAudits() throws Exception {
Response updateResponse = getLightblueFactory().getMediator().update(createRequest_FromJsonString(
UpdateRequest.class,
"{\"entity\":\"country\",\"entityVersion\":\"" + COUNTRY_VERSION + "\","
+ "\"projection\": [{\"field\":\"*\",\"include\":true,\"recursive\":true}],"
+ "\"query\":{\"field\":\"name\",\"op\":\"$in\",\"values\":[\"United States\",\"Canada\"]},"
+ "\"update\":["
+ "{\"$set\":{\"optionalField\":\"modified\"}}"
+ "]}"));
assertNoErrors(updateResponse);
assertNoDataErrors(updateResponse);
assertEquals(2, updateResponse.getModifiedCount());
Response findResponse = getLightblueFactory().getMediator().find(createRequest_FromJsonString(
FindRequest.class,
"{\"entity\":\"audit\",\"entityVersion\":\"" + AUDIT_VERSION + "\","
+ "\"query\":{\"field\":\"CRUDOperation\",\"op\":\"$eq\",\"rvalue\":\"UPDATE\"},"
+ "\"projection\": [{\"field\":\"*\",\"include\":true,\"recursive\":true}]}"));
assertNoErrors(findResponse);
assertNoDataErrors(findResponse);
assertEquals(2, findResponse.getMatchCount());
}
示例12: test3DeleteCreatesAudits
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void test3DeleteCreatesAudits() throws Exception {
Response deleteResponse = getLightblueFactory().getMediator().delete(createRequest_FromJsonString(
DeleteRequest.class,
"{\"entity\":\"country\",\"entityVersion\":\"" + COUNTRY_VERSION + "\","
+ "\"projection\": [{\"field\":\"*\",\"include\":true,\"recursive\":true}],"
+ "\"query\":{\"field\":\"name\",\"op\":\"$in\",\"values\":[\"United States\",\"Canada\"]}}"));
assertNoErrors(deleteResponse);
assertNoDataErrors(deleteResponse);
assertEquals(2, deleteResponse.getModifiedCount());
Response findResponse = getLightblueFactory().getMediator().find(createRequest_FromJsonString(
FindRequest.class,
"{\"entity\":\"audit\",\"entityVersion\":\"" + AUDIT_VERSION + "\","
+ "\"query\":{\"field\":\"CRUDOperation\",\"op\":\"$eq\",\"rvalue\":\"DELETE\"},"
+ "\"projection\": [{\"field\":\"*\",\"include\":true,\"recursive\":true}]}"));
assertNoErrors(findResponse);
assertNoDataErrors(findResponse);
assertEquals(2, findResponse.getMatchCount());
}
示例13: getDerivedOperationContext
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
public OperationContext getDerivedOperationContext(String entityName, CRUDFindRequest req) {
// Create a new request with same header information, but different query information
FindRequest newReq = new FindRequest();
newReq.shallowCopyFrom((Request) request, req);
newReq.setEntityVersion(new EntityVersion(entityName, resolver.getEntityMetadata(entityName).getVersion().getValue()));
// At this point, newReq has header information from the
// original request, but query information from the argument
// 'req'
return new OperationContext(newReq,
metadata,
getFactory(),
CRUDOperation.FIND,
resolver,
new ArrayList<DocCtx>(),
getCallerRoles(),
getHookManager());
}
示例14: findAndStream_ErrorHandling
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void findAndStream_ErrorHandling() throws Exception {
mdManager.md = null;
FindRequest req = new FindRequest();
req.setEntityVersion(new EntityVersion("foo", "0.0.1"));
mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
mockCrudController.findResponse = new CRUDFindResponse();
StreamingResponse response = mediator.findAndStream(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_UNKNOWN_ENTITY, response.getErrors().get(0).getErrorCode());
}
示例15: findResultMdTest
import com.redhat.lightblue.crud.FindRequest; //导入依赖的package包/类
@Test
public void findResultMdTest() throws Exception {
FindRequest req = new FindRequest();
req.setEntityVersion(new EntityVersion("test", "1.0"));
mdManager.md.getAccess().getFind().setRoles("anyone");
mockCrudController.findResponse = new CRUDFindResponse();
mockCrudController.findResponse.setSize(10);
mockCrudController.findCb=ctx->{
ArrayList<DocCtx> docs=new ArrayList<>();
for(int i=0;i<10;i++)
docs.add(new DocCtx(new JsonDoc(JsonNodeFactory.instance.objectNode()),getRmd(Integer.toString(i))));
ctx.setDocumentStream(new ListDocumentStream(docs));
};
Response response = mediator.find(req);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
Assert.assertEquals(0, response.getModifiedCount());
Assert.assertEquals(10, response.getMatchCount());
for(int i=0;i<10;i++) {
Assert.assertEquals(Integer.toString(i),response.getResultMetadata().get(i).getDocumentVersion());
}
}