コード例 #1
0
ファイル: UdlParser_UT.java プロジェクト: yileye/tellurium
 @Test
 public void testBaseUid() {
   CharStream stream = new ANTLRStringStream("Tellurium");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("Tellurium", data.getId());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
コード例 #2
0
ファイル: UdlParser_UT.java プロジェクト: yileye/tellurium
 @Test
 public void testListUidNoId() {
   CharStream stream = new ANTLRStringStream("{10}");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("_10", data.getId());
     assertTrue(data instanceof ListMetaData);
     ListMetaData lm = (ListMetaData) data;
     assertEquals("10", lm.getIndex().getValue());
     assertEquals(IndexType.VAL, lm.getIndex().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
コード例 #3
0
ファイル: UdlParser_UT.java プロジェクト: yileye/tellurium
 @Test
 public void testTableBodyMixedUid() {
   try {
     MetaData data = UidParser.parse("{row:3, column -> bad} as Search");
     assertNotNull(data);
     assertEquals("Search", data.getId());
     assertTrue(data instanceof TableBodyMetaData);
     TableBodyMetaData tbmd = (TableBodyMetaData) data;
     assertEquals("1", tbmd.getTbody().getValue());
     assertEquals(IndexType.VAL, tbmd.getTbody().getType());
     assertEquals("3", tbmd.getRow().getValue());
     assertEquals(IndexType.VAL, tbmd.getRow().getType());
     assertEquals("bad", tbmd.getColumn().getValue());
     assertEquals(IndexType.REF, tbmd.getColumn().getType());
   } catch (RecognitionException e) {
     e.printStackTrace();
     fail(e.getMessage());
   }
 }
コード例 #4
0
ファイル: UdlParser_UT.java プロジェクト: yileye/tellurium
 @Test
 public void testTableBodyRefUid() {
   CharStream stream = new ANTLRStringStream("{tbody : 1, row -> good, column -> bad} as Search");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("Search", data.getId());
     assertTrue(data instanceof TableBodyMetaData);
     TableBodyMetaData tbmd = (TableBodyMetaData) data;
     assertEquals("1", tbmd.getTbody().getValue());
     assertEquals(IndexType.VAL, tbmd.getTbody().getType());
     assertEquals("good", tbmd.getRow().getValue());
     assertEquals(IndexType.REF, tbmd.getRow().getType());
     assertEquals("bad", tbmd.getColumn().getValue());
     assertEquals(IndexType.REF, tbmd.getColumn().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
コード例 #5
0
ファイル: UdlParser_UT.java プロジェクト: yileye/tellurium
 @Test
 public void testTableBodyValUidNoId() {
   CharStream stream = new ANTLRStringStream("{tbody : 1, row : 2, column : 3}");
   UdlLexer lexer = new UdlLexer(stream);
   TokenStream tokenStream = new CommonTokenStream(lexer);
   UdlParser parser = new UdlParser(tokenStream);
   try {
     MetaData data = parser.uid();
     assertNotNull(data);
     assertEquals("_1_2_3", data.getId());
     assertTrue(data instanceof TableBodyMetaData);
     TableBodyMetaData tb = (TableBodyMetaData) data;
     assertEquals("1", tb.getTbody().getValue());
     assertEquals(IndexType.VAL, tb.getTbody().getType());
     assertEquals("2", tb.getRow().getValue());
     assertEquals(IndexType.VAL, tb.getRow().getType());
     assertEquals("3", tb.getColumn().getValue());
     assertEquals(IndexType.VAL, tb.getColumn().getType());
   } catch (RecognitionException e) {
     fail(e.getMessage());
   }
 }
  @Test
  public void testExampleJson() throws Exception {
    String json =
        FileUtil.readFileFromClasspath("json-examples/invoicing-rule-updated-example.json");
    JsonMessage jsonMessage = new JsonMessage(json);
    ServiceResult serviceResult = new ServiceResult();
    serviceResult.setRawData(jsonMessage);

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

    MetaData metaData = invoicingRuleCreated.getMetaData();

    InvoicingRule invoicingRule = invoicingRuleCreated.getInvoicingRule();

    List<InvoiceRecipient> invoiceRecipients = invoicingRule.getInvoiceRecipients();
    collector.checkThat(invoiceRecipients.size(), is(3));

    InvoiceRecipient invoiceRecipient = invoiceRecipients.get(0);

    Address registeredAddressInvoiceRecipient = invoiceRecipient.getRegisteredAddress();

    List<SplittingRule> splittingRules = invoiceRecipients.get(2).getSplittingRules();
    collector.checkThat(splittingRules.size(), is(3));
    SplittingRule splittingRule = splittingRules.get(0);

    List<PurchaseOrder> purchaseOrders = invoicingRule.getPurchaseOrders();
    collector.checkThat(purchaseOrders.size(), is(3));
    PurchaseOrder purchaseOrder = purchaseOrders.get(0);

    List<InvoicingRuleMessageRule> invoiceMessageRules = invoicingRule.getInvoiceMessageRules();
    collector.checkThat(invoiceMessageRules.size(), is(1));
    InvoicingRuleMessageRule invoiceMessageRule = invoiceMessageRules.get(0);

    collector.checkThat(metaData.getMessageType(), is("UpdateInvoicingRule"));
    collector.checkThat(
        metaData.getMessageId().getGuid(), is("28b62635-15a0-b15e-c5f4-5442b66d1059"));
    collector.checkThat(
        metaData.getCreationTime().getTimestamp(), is("2012-07-05T13:21:00.000+02:00"));
    collector.checkThat(metaData.getVersion(), is("1.0"));
    collector.checkThat(metaData.getSourceSystem(), is("CRM"));

    collector.checkThat(invoicingRule.getClientId(), is("TELIA"));
    collector.checkThat(invoicingRule.getMarketId().getOrganizationId(), is(51));
    collector.checkThat(
        invoicingRule.getInvoicingRuleId().getGuid(), is("3f2504e0-4f89-11d3-9a0c-0305e82c3405"));
    collector.checkThat(invoicingRule.getInvoicingRuleName(), is("Volvo - do not edit"));
    collector.checkThat(invoicingRule.getDescription(), is("Used in unit tests - do not edit"));
    collector.checkThat(invoicingRule.getIssuerReference(), is("Maria Lind"));
    collector.checkThat(invoicingRule.getClientReference(), is("Lasse Volvosson"));
    collector.checkThat(invoicingRule.getCurrencyCode().getCurrencyCode(), is("EUR"));
    collector.checkThat(invoicingRule.getDistributionMode().getValue(), is(1));
    collector.checkThat(invoicingRule.getTermsOfPayment().getDays(), is(30));
    collector.checkThat(invoicingRule.getPostingProfile().getValue(), is(1));
    collector.checkThat(invoicingRule.isDisplayTradeDoublerCommission(), is(true));
    collector.checkThat(invoicingRule.getRevenueType().getValue(), is(1));
    collector.checkThat(invoicingRule.getPaymentMethod().getValue(), is(2));
    collector.checkThat(invoicingRule.isDeviatingExchangeRate(), is(false));

    collector.checkThat(
        invoiceRecipient.getInvoiceRecipientId().getGuid(),
        is("703b123f-6329-4d79-bfaa-60762a5f6cf4"));
    collector.checkThat(
        invoiceRecipient.getInvoicingRuleId().getGuid(),
        is("3f2504e0-4f89-11d3-9a0c-0305e82c3405"));
    collector.checkThat(invoiceRecipient.getAttentionRow1(), is("Attention of default recipient!"));
    collector.checkThat(invoiceRecipient.getAttentionRow2(), nullValue());
    collector.checkThat(invoiceRecipient.getEmailAddress(), nullValue());
    collector.checkThat(invoiceRecipient.isDefaultRecipient(), is(true));

    collector.checkThat(registeredAddressInvoiceRecipient.getLine1(), is("AVD. 50090 HB3S"));
    collector.checkThat(registeredAddressInvoiceRecipient.getLine2(), nullValue());
    collector.checkThat(registeredAddressInvoiceRecipient.getCity(), is("Göteborg"));
    collector.checkThat(registeredAddressInvoiceRecipient.getCounty(), nullValue());
    collector.checkThat(registeredAddressInvoiceRecipient.getPostalCode(), is("40531"));
    collector.checkThat(registeredAddressInvoiceRecipient.getCountryCode().getValue(), is("SE"));
    collector.checkThat(registeredAddressInvoiceRecipient.getAddressType().getValue(), is(1));

    collector.checkThat(
        splittingRule.getSplittingRuleId().getGuid(), is("8f756919-c9ed-e111-8b5b-005056b45da6"));
    collector.checkThat(
        splittingRule.getInvoiceRecipientId().getGuid(),
        is("3ac9520d-c9ed-e111-8b5b-005056b45da6"));
    collector.checkThat(splittingRule.getSplitter(), is("kjhh567855"));

    collector.checkThat(
        purchaseOrder.getInvoicingRuleId().getGuid(), is("3f2504e0-4f89-11d3-9a0c-0305e82c3405"));
    collector.checkThat(purchaseOrder.getPoNumber(), is("234 - do not edit"));
    collector.checkThat(
        purchaseOrder.getPurchaseOrderId().getGuid(), is("00000000-0000-0000-4000-100000000001"));
    collector.checkThat(
        purchaseOrder.getValidFrom().getTimestamp(), is("2012-08-15T00:00:00.000+02:00"));
    collector.checkThat(
        purchaseOrder.getValidTo().getTimestamp(), is("2012-08-17T00:00:00.000+02:00"));

    collector.checkThat(
        invoiceMessageRule.getInvoiceMessageRuleId().getGuid(),
        is("00000000-0000-0000-3000-100000000001"));
    collector.checkThat(
        invoiceMessageRule.getInvoicingRuleId().getGuid(),
        is("3f2504e0-4f89-11d3-9a0c-0305e82c3405"));
    collector.checkThat(
        invoiceMessageRule.getMessageText(),
        is("This is a text to be printed on all invoices for this invoicing rule"));
    collector.checkThat(
        invoiceMessageRule.getValidFrom().getTimestamp(), is("2012-08-13T00:00:00.000+02:00"));
    collector.checkThat(
        invoiceMessageRule.getValidTo().getTimestamp(), is("2012-08-30T00:00:00.000+02:00"));
  }
コード例 #7
0
 @Test
 public void testGetNumberOfMacs() throws Exception {
   String fileName = "src/main/resources/meta_data.json";
   MetaData metaData = MetaDataReader.fromFile(fileName);
   assertThat(metaData.getNumberOfMacs(), is(127));
 }