NdsBeisEsb/src/test/java/com/northgateps/nds/beis/esb/getreferencevalues/GetReferenceValuesServiceRouteTest.java
/**
     * Runs the Get Reference Values Service camel route expecting a successful outcome
     */
Runs the Get Reference Values Service camel route expecting a successful outcome
Runs the Get Reference Values Service camel route expecting a successful outcome
@Test
    public void successPathTest() throws Exception {
        LOGGER.info("Starting success path test");
        LOGGER.info("Using endpoint " + context.resolvePropertyPlaceholders("{{apiGetReferenceValuesEndpoint}}") + " to run unit tests");
        context.getRouteDefinition(routeNameUnderTest).adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                weaveAddLast().to(MOCK_GSPS_RESPONSE_CHECK);
                replaceFromWith("direct:start");
                interceptSendToEndpoint("cxf:bean:beisGetReferenceValuesService").skipSendToOriginalEndpoint().to(
                        MOCK_GSPS_REQUEST_CHECK).process(new Processor() {
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        exchange.getIn().setBody(CreateGetReferenceValuesTestData.createGetReferenceValuesResponse());
                        CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
                        exchange.getIn().setBody(payload);
                    }
                });
            }
        });
        context.start();
        MockEndpoint getSysParametersServiceMock = getMockEndpoint(MOCK_GSPS_REQUEST_CHECK);
        getSysParametersServiceMock.expectedHeaderReceived(CxfConstants.OPERATION_NAME, getOperationName());
        MockEndpoint gspsRouteResponseMock = getMockEndpoint(MOCK_GSPS_RESPONSE_CHECK);
        gspsRouteResponseMock.expectedMessageCount(1);
        gspsRouteResponseMock.expectedBodiesReceived(JaxbXmlMarshaller.convertToPrettyPrintXml(
                CreateGetReferenceValuesTestData.createGetReferenceValuesNdsResponse(), GetReferenceValuesNdsResponse.class));
        apiEndpoint.sendBody(CreateGetReferenceValuesTestData.createGetReferenceValuesNdsRequest());
        assertMockEndpointsSatisfied();
    }
@ Test public void successPathTest ( ) throws Exception { LOGGER . info ( "Starting success path test" ) ; LOGGER . info ( "Using endpoint " + context . resolvePropertyPlaceholders ( "{{apiGetReferenceValuesEndpoint}}" ) + " to run unit tests" ) ; context . getRouteDefinition ( routeNameUnderTest ) . adviceWith ( context , new AdviceWithRouteBuilder ( ) { @ Override public void configure ( ) throws Exception { weaveAddLast ( ) . to ( MOCK_GSPS_RESPONSE_CHECK ) ; replaceFromWith ( "direct:start" ) ; interceptSendToEndpoint ( "cxf:bean:beisGetReferenceValuesService" ) . skipSendToOriginalEndpoint ( ) . to ( MOCK_GSPS_REQUEST_CHECK ) . process ( new Processor ( ) { @ Override public void process ( Exchange exchange ) throws Exception { exchange . getIn ( ) . setBody ( CreateGetReferenceValuesTestData . createGetReferenceValuesResponse ( ) ) ; CxfPayload < ? > payload = exchange . getIn ( ) . getBody ( CxfPayload . class ) ; exchange . getIn ( ) . setBody ( payload ) ; } } ) ; } } ) ; context . start ( ) ; MockEndpoint getSysParametersServiceMock = getMockEndpoint ( MOCK_GSPS_REQUEST_CHECK ) ; getSysParametersServiceMock . expectedHeaderReceived ( CxfConstants . OPERATION_NAME , getOperationName ( ) ) ; MockEndpoint gspsRouteResponseMock = getMockEndpoint ( MOCK_GSPS_RESPONSE_CHECK ) ; gspsRouteResponseMock . expectedMessageCount ( 1 ) ; gspsRouteResponseMock . expectedBodiesReceived ( JaxbXmlMarshaller . convertToPrettyPrintXml ( CreateGetReferenceValuesTestData . createGetReferenceValuesNdsResponse ( ) , GetReferenceValuesNdsResponse . class ) ) ; apiEndpoint . sendBody ( CreateGetReferenceValuesTestData . createGetReferenceValuesNdsRequest ( ) ) ; assertMockEndpointsSatisfied ( ) ; }
Runs the Get Reference Values Service camel route expecting a successful outcome
Runs the Get Reference Values Service camel route expecting a successful outcome
// mock out bits of the route to test that we are sending the right content to BEIS // and that we simulate the response from BEIS, and finally so that we can check // that the response back to the caller is correct // manually start the camel context.