Search in sources :

Example 1 with XpathMetadataService

use of com.adaptris.core.services.metadata.XpathMetadataService in project interlok by adaptris.

the class XStreamMarshallerTest method adapterInstanceFieldChecks.

// redmineID 2457 - ensures that marshalling/unmarshalling the given files results in no loss of data
public static void adapterInstanceFieldChecks(Adapter fromXML) {
    assertNotNull(fromXML);
    assertEquals("SimpleAdapterTest", fromXML.getUniqueId());
    assertTrue(fromXML.getEventHandler() instanceof DefaultEventHandler);
    assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getConnection() instanceof NullConnection);
    assertTrue(((DefaultEventHandler) fromXML.getEventHandler()).getProducer() instanceof NullMessageProducer);
    // ShutdownWaitSeconds is now null.
    assertNull(((DefaultEventHandler) fromXML.getEventHandler()).getShutdownWaitSeconds());
    assertTrue(fromXML.getMessageErrorHandler() instanceof NullProcessingExceptionHandler);
    Channel channel = fromXML.getChannelList().get(0);
    assertTrue(channel.getConsumeConnection() instanceof NullConnection);
    assertTrue(channel.getProduceConnection() instanceof NullConnection);
    // Check workflow
    WorkflowList workflowList = channel.getWorkflowList();
    assertNotNull(workflowList);
    assertEquals(1, workflowList.size());
    // test workflow
    StandardWorkflow standardWorkflow = (StandardWorkflow) workflowList.get(0);
    assertNotNull(standardWorkflow);
    assertEquals("workflow1", standardWorkflow.getUniqueId());
    // test workflow consumer
    NullMessageConsumer consumer = (NullMessageConsumer) standardWorkflow.getConsumer();
    assertNotNull(consumer);
    // test services
    ServiceCollection serviceCollection = standardWorkflow.getServiceCollection();
    assertNotNull(serviceCollection);
    assertEquals("serviceListID1", serviceCollection.getUniqueId());
    assertEquals(3, serviceCollection.size());
    assertTrue(serviceCollection instanceof ServiceList);
    // test service 1
    Service service1 = serviceCollection.get(0);
    assertEquals("serviceID1", service1.getUniqueId());
    assertTrue(service1 instanceof AddMetadataService);
    Set<MetadataElement> metadataElements = ((AddMetadataService) service1).getMetadataElements();
    assertEquals(1, metadataElements.size());
    for (Iterator<MetadataElement> iterator = metadataElements.iterator(); iterator.hasNext(); ) {
        MetadataElement metadataElement = iterator.next();
        assertEquals("key1", metadataElement.getKey());
        assertEquals("val1", metadataElement.getValue());
        break;
    }
    // test service 2
    Service service2 = serviceCollection.get(1);
    assertEquals("serviceID2", service2.getUniqueId());
    assertTrue(service2 instanceof XpathMetadataService);
    List<XpathQuery> xpathQueries = ((XpathMetadataService) service2).getXpathQueries();
    assertEquals(1, xpathQueries.size());
    assertEquals(ConfiguredXpathQuery.class, xpathQueries.get(0).getClass());
    assertEquals("/a/b/c", ((ConfiguredXpathQuery) xpathQueries.get(0)).getXpathQuery());
    // Test service3
    Service service3 = serviceCollection.get(2);
    assertEquals("serviceID3", service3.getUniqueId());
    assertTrue(service3 instanceof LogMessageService);
    assertTrue(StringUtils.isBlank(((LogMessageService) service3).getLogPrefix()));
}
Also used : LogMessageService(com.adaptris.core.services.LogMessageService) XpathMetadataService(com.adaptris.core.services.metadata.XpathMetadataService) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) XpathQuery(com.adaptris.core.services.metadata.xpath.XpathQuery) ConfiguredXpathQuery(com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery) XpathMetadataService(com.adaptris.core.services.metadata.XpathMetadataService)

Aggregations

LogMessageService (com.adaptris.core.services.LogMessageService)1 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)1 XpathMetadataService (com.adaptris.core.services.metadata.XpathMetadataService)1 ConfiguredXpathQuery (com.adaptris.core.services.metadata.xpath.ConfiguredXpathQuery)1 XpathQuery (com.adaptris.core.services.metadata.xpath.XpathQuery)1