Package org.openengsb.core.services.internal.xlink

Examples of org.openengsb.core.services.internal.xlink.ExampleObjectOrientedModel


    @Test
    public void testGenerateXLink_shouldSucceed() {
        String connectorId = "testConnector";
        String context = "foo";
        String testClassName = "TestClass";
        ExampleObjectOrientedModel modelObject = new ExampleObjectOrientedModel();
        modelObject.setOoClassName(testClassName);
        String xlink = connectorManager.generateXLink(connectorId, context, modelObject);

        assertNotNull(xlink);

        // Trim baseURL away
        xlink = xlink.substring(xlink.indexOf("?") + 1);
        // Get parameters out of the link
        Map<String, String> parameterMap = new HashMap<>();
        for (String parameter : xlink.split("&")) {
            String[] keyValue = parameter.split("=");
            if (keyValue.length == 2) {
                parameterMap.put(keyValue[0], keyValue[1]);
            }
        }

        assertEquals(context, parameterMap.get(XLinkConstants.XLINK_CONTEXTID_KEY));

        assertNotNull(parameterMap.get(XLinkConstants.XLINK_IDENTIFIER_KEY));

        String className = parameterMap.get(XLinkConstants.XLINK_MODELCLASS_KEY);
        assertEquals(ExampleObjectOrientedModel.class.getName(), className);

        ObjectMapper mapper = new ObjectMapper();
        // Needed because OpenEngSB model tail can not be used here
        mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);

        String model = parameterMap.get(XLinkConstants.XLINK_IDENTIFIER_KEY);
        ExampleObjectOrientedModel exampleModel = null;
        try {
            exampleModel = mapper.readValue(urlDecodeParameter(model), ExampleObjectOrientedModel.class);
        } catch (IOException e) {
            fail("Should not have been thrown.");
        }

        assertNotNull(exampleModel);
        assertEquals(testClassName, exampleModel.getOoClassName());
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.services.internal.xlink.ExampleObjectOrientedModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.