本文整理汇总了Java中com.redhat.lightblue.crud.FindRequest.setClientId方法的典型用法代码示例。如果您正苦于以下问题:Java FindRequest.setClientId方法的具体用法?Java FindRequest.setClientId怎么用?Java FindRequest.setClientId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.redhat.lightblue.crud.FindRequest
的用法示例。
在下文中一共展示了FindRequest.setClientId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: findQueryFieldRoleTest
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void findQueryFieldRoleTest() throws Exception {
FindRequest req = new FindRequest();
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-find")));
mockCrudController.findResponse = new CRUDFindResponse();
mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
Response response = mediator.find(req);
Assert.assertEquals(OperationStatus.ERROR, response.getStatus());
req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
response = mediator.find(req);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
示例3: testInsertWithRoles
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void testInsertWithRoles() throws Exception {
//Setup
String insert = AbstractJsonNodeTest.loadResource("./crud/insert/department-insert-template.json")
.replaceFirst("#cn", "Marketing")
.replaceFirst("#description", "Department devoted to Marketing")
.replaceFirst("#members",
"cn=John Doe," + BASEDB_USERS + "\",\"cn=Jane Doe," + BASEDB_USERS);
InsertionRequest insertRequest = createRequest_FromJsonString(InsertionRequest.class, insert);
insertRequest.setClientId(new FakeClientIdentification("fakeUser", "admin"));
//Test
Response response = getLightblueFactory().getMediator().insert(insertRequest);
assertValidResponse(response);
assertEquals(1, response.getModifiedCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{\"dn\":\"cn=Marketing," + BASEDB_DEPARTMENTS + "\"}]",
entityData.toString(), true);
//Ensure entry was inserted
FindRequest findRequest = createRequest_FromResource(FindRequest.class, "./crud/find/department-find.json");
findRequest.setClientId(new FakeClientIdentification("admin"));
Response findResponse = getLightblueFactory().getMediator().find(findRequest);
assertValidResponse(findResponse);
assertEquals(1, findResponse.getMatchCount());
}
示例4: testInsertWithInvalidRoles
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void testInsertWithInvalidRoles() throws Exception {
//Setup
String insert = AbstractJsonNodeTest.loadResource("./crud/insert/department-insert-template.json")
.replaceFirst("#cn", "HR")
.replaceFirst("#description", "Department devoted to HR")
.replaceFirst("#members", "cn=John Doe," + BASEDB_USERS);
InsertionRequest insertRequest = createRequest_FromJsonString(InsertionRequest.class, insert);
insertRequest.setClientId(new FakeClientIdentification("fakeUser"));
//Test
Response response = getLightblueFactory().getMediator().insert(insertRequest);
//Asserts
assertNotNull(response);
assertEquals(0, response.getModifiedCount());
assertNull(response.getEntityData());
assertNoErrors(response);
assertEquals(1, response.getDataErrors().size());
JSONAssert.assertEquals("{\"errors\":[{\"errorCode\":\"" + CrudConstants.ERR_NO_FIELD_INSERT_ACCESS + "\",\"msg\":\"member\"}]}",
response.getDataErrors().get(0).toJson().toString(), false);
//Ensure entry was not inserted
FindRequest findRequest = createRequest_FromResource(FindRequest.class, "./crud/find/department-find.json");
findRequest.setClientId(new FakeClientIdentification("admin"));
Response findResponse = getLightblueFactory().getMediator().find(findRequest);
assertValidResponse(findResponse);
assertEquals(0, findResponse.getMatchCount());
}
示例5: testFindWithRoles
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void testFindWithRoles() throws Exception {
//Setup
String insert = AbstractJsonNodeTest.loadResource("./crud/insert/department-insert-template.json")
.replaceFirst("#cn", "Marketing")
.replaceFirst("#description", "Department devoted to Marketing")
.replaceFirst("#members",
"cn=John Doe," + BASEDB_USERS + "\",\"cn=Jane Doe," + BASEDB_USERS);
InsertionRequest insertRequest = createRequest_FromJsonString(InsertionRequest.class, insert);
insertRequest.setClientId(new FakeClientIdentification("fakeUser", "admin"));
assertValidResponse(getLightblueFactory().getMediator().insert(insertRequest));
//Test
FindRequest findRequest = createRequest_FromResource(FindRequest.class, "./crud/find/department-find.json");
findRequest.setClientId(new FakeClientIdentification("fakeUser", "admin"));
Response response = getLightblueFactory().getMediator().find(findRequest);
assertValidResponse(response);
assertEquals(1, response.getMatchCount());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{\"member#\":2,\"member\":[\"cn=John Doe," + BASEDB_USERS + "\",\"cn=Jane Doe," + BASEDB_USERS + "\"],\"cn\":\"Marketing\",\"description\":\"Department devoted to Marketing\"}]",
entityData.toString(), true);
}
示例6: testFindWithInsufficientRoles
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void testFindWithInsufficientRoles() throws Exception {
//Setup
String insert = AbstractJsonNodeTest.loadResource("./crud/insert/department-insert-template.json")
.replaceFirst("#cn", "Marketing")
.replaceFirst("#description", "Department devoted to Marketing")
.replaceFirst("#members",
"cn=John Doe," + BASEDB_USERS + "\",\"cn=Jane Doe," + BASEDB_USERS);
InsertionRequest insertRequest = createRequest_FromJsonString(InsertionRequest.class, insert);
insertRequest.setClientId(new FakeClientIdentification("fakeUser", "admin"));
assertValidResponse(getLightblueFactory().getMediator().insert(insertRequest));
//Test
FindRequest findRequest = createRequest_FromResource(FindRequest.class, "./crud/find/department-find.json");
findRequest.setClientId(new FakeClientIdentification("fakeUser"));
Response response = getLightblueFactory().getMediator().find(findRequest);
assertValidResponse(response);
assertEquals(1, response.getMatchCount());
assertNotNull(response.getEntityData());
JsonNode entityData = response.getEntityData();
assertNotNull(entityData);
JSONAssert.assertEquals(
"[{\"cn\":\"Marketing\",\"description\":\"Department devoted to Marketing\"}]",
entityData.toString(), true);
}
示例7: optionalQueryTest
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void optionalQueryTest() throws Exception {
FindRequest req = new FindRequest();
req.setEntityVersion(new EntityVersion("test", "1.0"));
req.setClientId(new RestClientIdentification(Arrays.asList("test-find")));
mockCrudController.findResponse = new CRUDFindResponse();
mockCrudController.findCb=ctx->ctx.setDocumentStream(new ListDocumentStream<DocCtx>(new ArrayList<DocCtx>()));
Response response = mediator.find(req);
Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
示例8: getSavedSearchFromDB
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
/**
* Retrieves a saved search from the database.
*
* @param m Mediator instance
* @param clid The client id
* @param searchName name of the saved search
* @param entit Name of the entity
* @param version Entity version the search should run on
*
* The returned JsonNode can be an ObjectNode, or an ArrayNode
* containing zero or more documents. If there are more than one
* documents, only one of them is for the requested version, and
* the other is for the null version that applies to all
* versions. It returns null or empty array if nothing is found.
* In case of retrieval error, a RetrievalError is thrown
* containing the errors.
*/
public JsonNode getSavedSearchFromDB(Mediator m,
ClientIdentification clid,
String searchName,
String entity,
String version) {
FindRequest findRequest=new FindRequest();
findRequest.setEntityVersion(new EntityVersion(savedSearchEntity,savedSearchVersion));
findRequest.setClientId(clid);
List<Value> versionList=new ArrayList<>(2);
versionList.add(NULL_VALUE);
// Include all segments of the version in the search list
if(version!=null) {
int index=0;
while((index=version.indexOf('.',index))!=-1) {
versionList.add(new Value(version.substring(0,index)));
index++;
}
versionList.add(new Value(version));
}
QueryExpression q=new NaryLogicalExpression(NaryLogicalOperator._and,
new ValueComparisonExpression(P_NAME,
BinaryComparisonOperator._eq,
new Value(searchName)),
new ValueComparisonExpression(P_ENTITY,
BinaryComparisonOperator._eq,
new Value(entity)),
new ArrayContainsExpression(P_VERSIONS,
ContainsOperator._any,
versionList));
LOGGER.debug("Searching {}",q);
findRequest.setQuery(q);
findRequest.setProjection(FieldProjection.ALL);
Response response=m.find(findRequest);
if(response.getErrors()!=null&&!response.getErrors().isEmpty())
throw new RetrievalError(response.getErrors());
LOGGER.debug("Found {}",response.getEntityData());
return response.getEntityData();
}
示例9: buildRequest
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
/**
* Builds a find request from the saved search by rewriting the
* search bound parameters using parameter values. The search
* query components can be either strings, or JSON objects. If
* they are strings, the parameters are replaced first, then the
* resulting json string is converted to a query/projection. If
* the components are JSON objects, then the values of those json
* objects are replaced with parameter values.
*/
public static FindRequest buildRequest(JsonNode savedSearch,
String entity,
String version,
ClientIdentification clid,
Map<String,String> parameterValues)
throws IOException {
FindRequest request=new FindRequest();
request.setEntityVersion(new EntityVersion(entity,version));
request.setClientId(clid);
JsonNode node=savedSearch.get("query");
if(node instanceof TextNode) {
request.setQuery(QueryExpression.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
} else {
request.setQuery(QueryExpression.fromJson(applyParameters(node,parameterValues)));
}
node=savedSearch.get("projection");
if(node instanceof ArrayNode||
node instanceof ObjectNode) {
request.setProjection(Projection.fromJson(applyParameters(node,parameterValues)));
} else if(node instanceof TextNode) {
request.setProjection(Projection.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
}
node=savedSearch.get("sort");
if(node instanceof ArrayNode||
node instanceof ObjectNode) {
request.setSort(Sort.fromJson(applyParameters(node,parameterValues)));
} else if(node instanceof TextNode) {
request.setSort(Sort.fromJson(JsonUtils.json(applyParameters(node.asText(),parameterValues))));
}
node=savedSearch.get("range");
if(node instanceof ArrayNode) {
if(node.size()==2) {
request.setFrom(node.get(0).asLong());
request.setTo(node.get(1).asLong());
}
}
return request;
}
示例10: parallelOrderedBulkTest
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void parallelOrderedBulkTest() throws Exception {
BulkRequest breq = new BulkRequest();
FindRequest freq = new FindRequest();
freq.setEntityVersion(new EntityVersion("test", "1.0"));
freq.setClientId(new RestClientIdentification(Arrays.asList("test-find")));
InsertionRequest ireq = new InsertionRequest();
ireq.setEntityVersion(new EntityVersion("test", "1.0"));
ireq.setEntityData(loadJsonNode("./sample1.json"));
ireq.setReturnFields(null);
ireq.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
breq.add(freq);
breq.add(freq);
breq.add(freq);
breq.add(ireq);
breq.add(freq);
breq.add(freq);
breq.add(ireq);
PFindCb findCb = new PFindCb();
PInsertCb insertCb = new PInsertCb();
((TestMediator) mediator).findCb = findCb;
((TestMediator) mediator).insertCb = insertCb;
ValidatorThread validator = new ValidatorThread(findCb, insertCb) {
@Override
public void run() {
try {
LOGGER.debug("Check if all 3 finds are waiting");
while (find.nested.get() < 3) {
Thread.sleep(1);
}
LOGGER.debug("Let the 3 find requests complete");
find.sem.release(3);
LOGGER.debug("Busy wait");
while (find.sem.availablePermits() > 0) {
Thread.sleep(1);
}
LOGGER.debug("Let insert complete");
insert.sem.release(1);
while (insert.sem.availablePermits() > 0) {
Thread.sleep(1);
}
LOGGER.debug("Check if all 2 finds are waiting");
while (find.nested.get() < 2) {
Thread.sleep(1);
}
LOGGER.debug("Let the remaining 2 find requests complete");
find.sem.release(2);
while (find.sem.availablePermits() > 0) {
Thread.sleep(1);
}
insert.sem.release(1);
while (insert.sem.availablePermits() > 0) {
Thread.sleep(1);
}
LOGGER.debug("Complete");
valid = true;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
validator.start();
LOGGER.debug("Ordered exec");
BulkResponse bresp = mediator.bulkRequest(breq, noopMetrics);
validator.join();
LOGGER.debug("Ordered exec done");
Assert.assertTrue(validator.valid);
}
示例11: parallelUnorderedBulkTest
import com.redhat.lightblue.crud.FindRequest; //导入方法依赖的package包/类
@Test
public void parallelUnorderedBulkTest() throws Exception {
BulkRequest breq = new BulkRequest();
breq.setOrdered(false);
FindRequest freq = new FindRequest();
freq.setEntityVersion(new EntityVersion("test", "1.0"));
freq.setClientId(new RestClientIdentification(Arrays.asList("test-find")));
InsertionRequest ireq = new InsertionRequest();
ireq.setEntityVersion(new EntityVersion("test", "1.0"));
ireq.setEntityData(loadJsonNode("./sample1.json"));
ireq.setReturnFields(null);
ireq.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
breq.add(freq);
breq.add(freq);
breq.add(ireq);
breq.add(freq);
breq.add(freq);
breq.add(ireq);
breq.add(freq);
PFindCb findCb = new PFindCb();
PInsertCb insertCb = new PInsertCb();
((TestMediator) mediator).findCb = findCb;
((TestMediator) mediator).insertCb = insertCb;
ValidatorThread validator = new ValidatorThread(findCb, insertCb) {
@Override
public void run() {
try {
// Wait until all 7 calls started
while (find.nested.get() + insert.nested.get() < 7) {
Thread.sleep(1);
}
// Let them all complete
find.sem.release(5);
insert.sem.release(2);
// Wait until they're all completed
while(find.nested.get() > 0 && insert.nested.get() > 0) {
Thread.sleep(1);
}
valid = true;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
validator.start();
LOGGER.debug("Unordered exec");
mediator.bulkRequest(breq, noopMetrics);
validator.join();
LOGGER.debug("Unordered exec done");
Assert.assertTrue(validator.valid);
}