public static Map<?, ?> getItem(CamelContext camelctx) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.GetItem) .withHeader(DdbConstants.KEY, key).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); return exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class); }
public static Map<?, ?> getItem(CamelContext camelctx) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.GetItem) .withHeader(DdbConstants.KEY, key).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); return exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class); }
public static void putItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> putItem = new HashMap<>(); putItem.put("Id", new AttributeValue().withN("103")); putItem.put("Title", new AttributeValue().withS(title)); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.PutItem) .withHeader(DdbConstants.ITEM, putItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); }
public static void putItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> putItem = new HashMap<>(); putItem.put("Id", new AttributeValue().withN("103")); putItem.put("Title", new AttributeValue().withS(title)); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.PutItem) .withHeader(DdbConstants.ITEM, putItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); }
public static void updItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); HashMap<String, AttributeValueUpdate> updItem = new HashMap<>(); AttributeValueUpdate updValue = new AttributeValueUpdate(); updValue.setValue(new AttributeValue().withS(title)); updItem.put("Title", updValue); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.UpdateItem) .withHeader(DdbConstants.KEY, key) .withHeader(DdbConstants.UPDATE_VALUES, updItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); }
public static void updItem(CamelContext camelctx, String title) { HashMap<String, AttributeValue> key = new HashMap<>(); key.put("Id", new AttributeValue().withN("103")); HashMap<String, AttributeValueUpdate> updItem = new HashMap<>(); AttributeValueUpdate updValue = new AttributeValueUpdate(); updValue.setValue(new AttributeValue().withS(title)); updItem.put("Title", updValue); Exchange exchange = new ExchangeBuilder(camelctx) .withHeader(DdbConstants.OPERATION, DdbOperations.UpdateItem) .withHeader(DdbConstants.KEY, key) .withHeader(DdbConstants.UPDATE_VALUES, updItem).build(); ProducerTemplate producer = camelctx.createProducerTemplate(); producer.send("direct:start", exchange); Assert.assertNull(exchange.getException()); }
@Test public void mockEndpoint_snapshotsTheExchange() throws Exception { // Given weaveRoute(GreetingRouteBuilder.ROUTE_ID, routeBuilder -> routeBuilder.weaveByToString(".*ocessor.*") .replace() .to(mockEndpoint)); // And Exchange inputExchange = new ExchangeBuilder(camelContext) .withBody("Duke") .build(); // When producerTemplate.send(inputExchange); Exchange mockEndpointExchange = mockEndpoint.getExchanges().get(0); // Then assertThat(mockEndpointExchange.getExchangeId()).isEqualTo(inputExchange.getExchangeId()); // And assertThat(mockEndpointExchange.getProperty(FIRST_PROPERTY)).isEqualTo("Hello Duke"); assertThat(mockEndpointExchange.getProperty(SECOND_PROPERTY)).isNull(); // And assertThat(inputExchange.getProperty(FIRST_PROPERTY)).isEqualTo("Hello Duke"); assertThat(inputExchange.getProperty(SECOND_PROPERTY)).isEqualTo("Goodbye Duke"); // And assertThat(mockEndpointExchange).isNotSameAs(inputExchange); }