• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.redhat.lightblue.Response的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Response类属于com.redhat.lightblue包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: verifyEvent

import com.redhat.lightblue.Response; //导入依赖的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);
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-esb-hook,代码行数:19,代码来源:BasePublishHookTest.java


示例2: test1CustomerInsertWithProperties

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void test1CustomerInsertWithProperties() throws Exception {
    Response response = getLightblueFactory().getMediator().insert(
            createRequest_FromResource(InsertionRequest.class, "./crud/insert/customer-insert-single.json"));

    assertNotNull(response);
    assertNoErrors(response);
    assertNoDataErrors(response);
    assertEquals(1, response.getModifiedCount());

    JsonNode entityData = response.getEntityData();
    assertNotNull(entityData);
    JSONAssert.assertEquals(
            "[{\"id\":\"uid=frodo.baggins," + BASEDB_CUSTOMERS + "\"}]",
            entityData.toString(), false);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:17,代码来源:ITCaseLdapCRUDController_WithProperties_Test.java


示例3: test2FindCustomerWithProperties

import com.redhat.lightblue.Response; //导入依赖的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


示例4: assertPersonEntryValues

import com.redhat.lightblue.Response; //导入依赖的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);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:18,代码来源:ITCaseLdapCRUDControllerTest.java


示例5: testDelete

import com.redhat.lightblue.Response; //导入依赖的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());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:22,代码来源:ITCaseLdapCRUDControllerTest.java


示例6: testFindMany

import com.redhat.lightblue.Response; //导入依赖的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);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:26,代码来源:ITCaseLdapCRUDControllerTest.java


示例7: testFindMany_WithPagination

import com.redhat.lightblue.Response; //导入依赖的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);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:21,代码来源:ITCaseLdapCRUDControllerTest.java


示例8: test1PersonWithAddress_Insert

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void test1PersonWithAddress_Insert() throws Exception {
    Response response = getLightblueFactory().getMediator().insert(
            createRequest_FromResource(InsertionRequest.class, "./crud/insert/person-with-address-insert-single.json"));

    assertNotNull(response);
    assertNoErrors(response);
    assertNoDataErrors(response);
    assertEquals(1, response.getModifiedCount());

    JsonNode entityData = response.getEntityData();
    assertNotNull(entityData);
    JSONAssert.assertEquals(
            "[{\"dn\":\"uid=john.doe," + BASEDB_USERS + "\"}]",
            entityData.toString(), false);
}
 
开发者ID:lightblue-platform,项目名称:lightblue-ldap,代码行数:17,代码来源:ITCaseLdapCRUDController_Objects_Test.java


示例9: test2PersonWithAddress_Find

import com.redhat.lightblue.Response; //导入依赖的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


示例10: test2UpdateCreatesAudits

import com.redhat.lightblue.Response; //导入依赖的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());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-audit-hook,代码行数:24,代码来源:ITAuditHook.java


示例11: test3DeleteCreatesAudits

import com.redhat.lightblue.Response; //导入依赖的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());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-audit-hook,代码行数:21,代码来源:ITAuditHook.java


示例12: toJson

import com.redhat.lightblue.Response; //导入依赖的package包/类
/**
 * Returns a JSON representation of this
 */
@Override
public JsonNode toJson() {
    JsonNodeFactory factory = getFactory();
    ObjectNode node = factory.objectNode();
    ArrayNode arr = factory.arrayNode();
    int seq = 0;
    for (Response x : entries) {
        ObjectNode entryNode = factory.objectNode();
        entryNode.set("seq", factory.numberNode(seq++));
        entryNode.set("response", x.toJson());
        arr.add(entryNode);
    }
    node.put("responses", arr);
    return node;
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:19,代码来源:BulkResponse.java


示例13: setResultSizeThresholds

import com.redhat.lightblue.Response; //导入依赖的package包/类
/**
 * Bulk result set size threshold is expressed in bytes. This is just an approximation, see @{link {@link JsonUtils#size(JsonNode)} for details.
 *
 * @param maxResultSetSizeB error when this threshold is breached
 * @param warnResultSetSizeB log a warning when this threshold is breached
 * @param forRequest request which resulted in this response, for logging purposes
 */
public void setResultSizeThresholds(int maxResultSetSizeB, int warnResultSetSizeB, BulkRequest forRequest) {

    this.memoryMonitor = new MemoryMonitor<>((response) -> response.getResponseDataSizeB());

    memoryMonitor.registerMonitor(new ThresholdMonitor<Response>(maxResultSetSizeB, (current, threshold, response) -> {
        // remove data
        response.setEntityData(JsonNodeFactory.instance.arrayNode());
        response.getErrors().add(Error.get(Response.ERR_RESULT_SIZE_TOO_LARGE, current+"B > "+threshold+"B"));
    }));

    memoryMonitor.registerMonitor(new ThresholdMonitor<Response>(warnResultSetSizeB, (current, threshold, response) -> {
        LOGGER.warn("crud:ResultSizeIsLarge: request={}, responseDataSizeB={}", forRequest, current);
    }));

}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:23,代码来源:BulkExecutionContext.java


示例14: testDependencies

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void testDependencies() {
    String entityName = "fake";
    String version1 = "1.0.0";
    String version2 = "2.0.0";

    FakeMetadata metadata = new FakeMetadata();

    EntityInfo entityInfo = new EntityInfo(entityName);
    metadata.setEntityInfo(entityInfo);

    assertEquals(entityInfo, metadata.getEntityInfo(entityName));

    Response dependencies = new Response(JsonNodeFactory.instance, OperationStatus.ERROR);
    metadata.setDependencies(entityName, version1, dependencies);

    assertEquals(dependencies, metadata.getDependencies(entityName, version1));
    assertNull(metadata.getDependencies(entityName, version2));
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:20,代码来源:FakeMetadataTest.java


示例15: insertRoleAccessTest

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void insertRoleAccessTest() throws Exception {
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test-insert", "test-update")));
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);
    Response response = mediator.insert(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());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:18,代码来源:MediatorTest.java


示例16: insertFieldAccessTest

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void insertFieldAccessTest() throws Exception {
    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test.field1-insert", "test-insert")));
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);

    Response response = mediator.insert(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());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:19,代码来源:MediatorTest.java


示例17: insertDocWithRequiredFieldNull

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void insertDocWithRequiredFieldNull() throws Exception {
    mdManager.md = getMd("./termsmd.json");

    InsertionRequest req = new InsertionRequest();
    req.setEntityVersion(new EntityVersion("terms", "0.14.1-SNAPSHOT"));
    req.setEntityData(loadJsonNode("./termsdata.json"));
    req.setReturnFields(null);
    req.setClientId(new RestClientIdentification(Arrays.asList("test.field1-insert", "test-insert")));
    // lastUpdatedBy is required, set that to null
    ((ObjectNode) req.getEntityData()).set("lastUpdatedBy", JsonNodeFactory.instance.nullNode());
    mockCrudController.insertResponse=new CRUDInsertionResponse();
    mockCrudController.insertResponse.setNumInserted(1);

    Response response = mediator.insert(req);
    // there should be no errors
    // Response should return the entity name:version
    Assert.assertEquals("terms",response.getEntity().getEntity());
    Assert.assertEquals("0.14.1-SNAPSHOT",response.getEntity().getVersion());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:21,代码来源:MediatorTest.java


示例18: saveResultMdTest

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void saveResultMdTest() throws Exception {
    SaveRequest req = new SaveRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setEntityData(loadJsonNode("./sample1.json"));
    req.setReturnFields(null);
    mockCrudController.saveResponse=new CRUDSaveResponse();
    mockCrudController.saveResponse.setNumSaved(1);
    mockCrudController.saveCb=ctx->{ctx.getInputDocuments().get(0).setResultMetadata(getRmd("1"));};

    mdManager.md.getAccess().getInsert().setRoles("anyone");
    mdManager.md.getAccess().getUpdate().setRoles("anyone");
    Response response = mediator.save(req);

    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
    Assert.assertEquals(1, response.getModifiedCount());
    Assert.assertEquals(1,response.getResultMetadata().size());
    Assert.assertEquals("1",response.getResultMetadata().get(0).getDocumentVersion());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:20,代码来源:MediatorTest.java


示例19: updateQueryFieldRoleTest

import com.redhat.lightblue.Response; //导入依赖的package包/类
@Test
public void updateQueryFieldRoleTest() throws Exception {
    UpdateRequest req = new UpdateRequest();
    req.setEntityVersion(new EntityVersion("test", "1.0"));
    req.setReturnFields(null);
    req.setQuery(new ValueComparisonExpression(new Path("field1"), BinaryComparisonOperator._eq, new Value("x")));
    req.setClientId(new RestClientIdentification(Arrays.asList("test-update")));

    mockCrudController.updateResponse = new CRUDUpdateResponse();
    Response response = mediator.update(req);
    Assert.assertEquals(OperationStatus.ERROR, response.getStatus());

    req.setQuery(new ValueComparisonExpression(new Path("field2"), BinaryComparisonOperator._eq, new Value("x")));
    response = mediator.update(req);
    Assert.assertEquals(OperationStatus.COMPLETE, response.getStatus());
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:17,代码来源:MediatorTest.java


示例20: findResultMdTest

import com.redhat.lightblue.Response; //导入依赖的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());
    }
}
 
开发者ID:lightblue-platform,项目名称:lightblue-core,代码行数:23,代码来源:MediatorTest.java



注:本文中的com.redhat.lightblue.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BubbleChart类代码示例发布时间:2022-05-22
下一篇:
Java ExporterUtil类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap