use of java.util.ArrayList in project camel by apache.
the class EC2ProducerTest method ec2DescribeStatusSpecificInstancesTest.
@Test
public void ec2DescribeStatusSpecificInstancesTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:describeStatus", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
assertMockEndpointsSatisfied();
DescribeInstanceStatusResult resultGet = (DescribeInstanceStatusResult) exchange.getIn().getBody();
assertEquals(resultGet.getInstanceStatuses().size(), 1);
assertEquals(resultGet.getInstanceStatuses().get(0).getInstanceState().getName(), InstanceStateName.Running.toString());
}
use of java.util.ArrayList in project camel by apache.
the class EC2ProducerTest method ec2StopTest.
@Test
public void ec2StopTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:stop", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
assertMockEndpointsSatisfied();
StopInstancesResult resultGet = (StopInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getStoppingInstances().get(0).getInstanceId(), "test-1");
assertEquals(resultGet.getStoppingInstances().get(0).getPreviousState().getName(), InstanceStateName.Running.toString());
assertEquals(resultGet.getStoppingInstances().get(0).getCurrentState().getName(), InstanceStateName.Stopped.toString());
}
use of java.util.ArrayList in project camel by apache.
the class EC2ProducerTest method ec2StartTest.
@Test
public void ec2StartTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:start", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
assertMockEndpointsSatisfied();
StartInstancesResult resultGet = (StartInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getStartingInstances().get(0).getInstanceId(), "test-1");
assertEquals(resultGet.getStartingInstances().get(0).getPreviousState().getName(), InstanceStateName.Stopped.toString());
assertEquals(resultGet.getStartingInstances().get(0).getCurrentState().getName(), InstanceStateName.Running.toString());
}
use of java.util.ArrayList in project camel by apache.
the class BindyCsvFactory method initAnnotatedFields.
@Override
public void initAnnotatedFields() {
maxpos = 0;
for (Class<?> cl : models) {
List<Field> linkFields = new ArrayList<Field>();
if (LOG.isDebugEnabled()) {
LOG.debug("Class retrieved: {}", cl.getName());
}
for (Field field : cl.getDeclaredFields()) {
DataField dataField = field.getAnnotation(DataField.class);
if (dataField != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Position defined in the class: {}, position: {}, Field: {}", new Object[] { cl.getName(), dataField.pos(), dataField });
}
if (dataField.required()) {
++numberMandatoryFields;
} else {
++numberOptionalFields;
}
int pos = dataField.pos();
if (annotatedFields.containsKey(pos)) {
Field f = annotatedFields.get(pos);
LOG.warn("Potentially invalid model: existing @DataField '{}' replaced by '{}'", f.getName(), field.getName());
}
dataFields.put(pos, dataField);
annotatedFields.put(pos, field);
maxpos = Math.max(maxpos, pos);
}
Link linkField = field.getAnnotation(Link.class);
if (linkField != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Class linked: {}, Field: {}", cl.getName(), field);
}
linkFields.add(field);
}
}
if (!linkFields.isEmpty()) {
annotatedLinkFields.put(cl.getName(), linkFields);
}
totalFields = numberMandatoryFields + numberOptionalFields;
if (LOG.isDebugEnabled()) {
LOG.debug("Number of optional fields: {}", numberOptionalFields);
LOG.debug("Number of mandatory fields: {}", numberMandatoryFields);
LOG.debug("Total: {}", totalFields);
}
}
if (annotatedFields.size() < maxpos) {
LOG.info("Potentially incomplete model: some csv fields may not be mapped to @DataField members");
}
}
use of java.util.ArrayList in project camel by apache.
the class CsvTest method testUnmarshal.
/*
@Test
public void testMarshal() throws Exception {
List<Employee> employees = getEmployees();
MockEndpoint mock = getMockEndpoint("mock:beanio-marshal");
mock.expectedBodiesReceived(FIXED_DATA);
template.sendBody("direct:marshal", employees);
mock.assertIsSatisfied();
}
*/
@Test
public void testUnmarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:beanio-unmarshal");
mock.expectedMessageCount(2);
template.sendBody("direct:unmarshal", FIXED_DATA);
mock.assertIsSatisfied();
List<Exchange> exchanges = mock.getExchanges();
if (verbose) {
for (Exchange exchange : exchanges) {
Object body = exchange.getIn().getBody();
log.info("received message {} of class {}", body, body.getClass().getName());
}
}
List<Map> results = new ArrayList<Map>();
for (Exchange exchange : exchanges) {
Map body = exchange.getIn().getBody(Map.class);
if (body != null) {
results.add(body);
}
}
assertRecord(results, 0, "James", "Strachan", 22);
assertRecord(results, 1, "Claus", "Ibsen", 21);
}
Aggregations