コード例 #1
0
  @Test
  public void testExampleJson() throws Exception {
    String json = FileUtil.readFileFromClasspath("json-examples/agreement-updated-example.json");
    JsonMessage jsonMessage = new JsonMessage(json);
    ServiceResult serviceResult = new ServiceResult();
    serviceResult.setRawData(jsonMessage);

    ServiceResult result = (ServiceResult) transformer.doTransform(serviceResult, "UTF-8");
    AgreementUpdated agreementUpdated =
        (AgreementUpdated) result.getIntegrationMessage().getDomainObject();

    Agreement agreement = agreementUpdated.getAgreement();

    collector.checkThat(agreement.getCurrencyCode().getCurrencyCode(), is("SEK"));
    collector.checkThat(
        agreement.getDocumentLink(), is("\\\\someserver\\somefolder\\somefile.pdf"));
    collector.checkThat(agreement.getClientId(), is("Cl42824050"));
    collector.checkThat(agreement.getDescription(), is("Agreement Name Example"));
    collector.checkThat(agreement.getSourceSystemAgreementId(), is("1-1234567896"));
    collector.checkThat(
        agreement.getValidFrom().getTimestamp(), is("2012-06-25T15:30:01.999+02:00"));
    collector.checkThat(agreement.getValidTo(), nullValue());
    collector.checkThat(
        agreement.getInvoicingRuleId().getGuid(), is("3f2504e0-4f89-11d3-9a0c-0305e82c3401"));
    collector.checkThat(agreement.getMarketId().getOrganizationId(), is(51));
    collector.checkThat(agreement.getProductType().getValue(), is(3));
  }
コード例 #2
0
  @Test
  public void testEmptyJson() throws Exception {
    JsonMessage jsonMessage = new JsonMessage("");
    ServiceResult serviceResult = new ServiceResult();
    serviceResult.setRawData(jsonMessage);

    ServiceResult result = (ServiceResult) transformer.doTransform(serviceResult, "UTF-8");
    assertNull(result.getIntegrationMessage());
    collector.checkThat(result.isBugDisturbance(), is(true));
    assertThat(
        result.getErrorMessage(),
        is(
            "Was not able to transform class class com.tradedoubler.billing.domain.AgreementUpdated"));
  }