@Test
public void testPrePopulateDcaeMsPolicyData() {

    logger.debug("testPrePopulateDCAEMSPolicyData: enter");
    CreateDcaeMicroServiceController controller = new CreateDcaeMicroServiceController();
    // populate an entity object for testing
    PolicyEntity entity = new PolicyEntity();
    ConfigurationDataEntity configData = new ConfigurationDataEntity();
    configData.setConfigBody(configBodyString);
    entity.setConfigurationData(configData);
    JsonNode root = null;
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    PolicyRestAdapter restAdapter = null;
    try {
        root = JsonLoader.fromString(jsonString);
        restAdapter = mapper.readValue(root.get("policyData").get("policy").toString(), PolicyRestAdapter.class);
        // create guard attribute
        MatchType matchType = new MatchType();
        // set value
        AttributeValueType attributeValue1 = new AttributeValueType();
        attributeValue1.getContent().add("True");
        matchType.setAttributeValue(attributeValue1);
        // set Id
        AttributeDesignatorType designator = new AttributeDesignatorType();
        designator.setAttributeId("guard");
        matchType.setAttributeDesignator(designator);
        AllOfType alltype = new AllOfType();
        alltype.getMatch().add(matchType);
        // add a dummy MatchType object since while (matchList.size()>1 ...)
        MatchType matchDummy = new MatchType();
        // set value
        AttributeValueType dummyValue = new AttributeValueType();
        dummyValue.getContent().add("dummy");
        matchDummy.setAttributeValue(dummyValue);
        // set Id
        AttributeDesignatorType designatorDummy = new AttributeDesignatorType();
        designatorDummy.setAttributeId("dummyId");
        matchDummy.setAttributeDesignator(designatorDummy);
        alltype.getMatch().add(matchDummy);
        AnyOfType anyOfType = new AnyOfType();
        anyOfType.getAllOf().add(alltype);
        TargetType target = new TargetType();
        target.getAnyOf().add(anyOfType);
        // create RiskType attribute
        AnyOfType anyRiskType = new AnyOfType();
        AllOfType allRiskType = new AllOfType();
        MatchType matchRiskType = new MatchType();
        // set value
        AttributeValueType riskTypeValue = new AttributeValueType();
        riskTypeValue.getContent().add("test");
        matchRiskType.setAttributeValue(riskTypeValue);
        // set Id
        AttributeDesignatorType designatorRiskType = new AttributeDesignatorType();
        designatorRiskType.setAttributeId("RiskType");
        matchRiskType.setAttributeDesignator(designatorRiskType);
        allRiskType.getMatch().add(matchRiskType);
        // add a dummy MatchType object since while (matchList.size()>1 ...)
        MatchType matchDummy1 = new MatchType();
        // set value
        AttributeValueType dummy1Value = new AttributeValueType();
        dummy1Value.getContent().add("dummy");
        matchDummy1.setAttributeValue(dummy1Value);
        // set Id
        AttributeDesignatorType designatorDummy1 = new AttributeDesignatorType();
        designatorDummy1.setAttributeId("dummyId");
        matchDummy1.setAttributeDesignator(designatorDummy1);
        allRiskType.getMatch().add(matchDummy1);
        anyRiskType.getAllOf().add(allRiskType);
        target.getAnyOf().add(anyRiskType);
        // create RiskLevel attribute
        MatchType matchRiskLevel = new MatchType();
        // set value
        AttributeValueType riskLevel = new AttributeValueType();
        riskLevel.getContent().add("3");
        matchRiskLevel.setAttributeValue(riskLevel);
        // set Id
        AttributeDesignatorType designatorRiskLevel = new AttributeDesignatorType();
        designatorRiskLevel.setAttributeId("RiskLevel");
        matchRiskLevel.setAttributeDesignator(designatorRiskLevel);
        AllOfType allRiskLevel = new AllOfType();
        allRiskLevel.getMatch().add(matchRiskLevel);
        // add a dummy MatchType object since while (matchList.size()>1 ...)
        MatchType matchDummy2 = new MatchType();
        // set value
        AttributeValueType dummy2Value = new AttributeValueType();
        dummy2Value.getContent().add("dummy");
        matchDummy2.setAttributeValue(dummy2Value);
        // set Id
        AttributeDesignatorType designatorDummy2 = new AttributeDesignatorType();
        designatorDummy2.setAttributeId("dummyId");
        matchDummy2.setAttributeDesignator(designatorDummy2);
        allRiskLevel.getMatch().add(matchDummy2);
        AnyOfType anyRiskLevel = new AnyOfType();
        anyRiskLevel.getAllOf().add(allRiskLevel);
        target.getAnyOf().add(anyRiskLevel);
        PolicyType policyType = new PolicyType();
        policyType.setTarget(target);
        restAdapter.setPolicyData(policyType);
        controller.prePopulateDCAEMSPolicyData(restAdapter, entity);
        logger.error("restAdapter.getRiskType() : " + restAdapter.getRiskType());
        logger.error("restAdapter.getRiskLevel() : " + restAdapter.getRiskLevel());
        logger.error("restAdapter.getGuard() : " + restAdapter.getGuard());
        assertEquals("True", restAdapter.getGuard());
        assertEquals("3", restAdapter.getRiskLevel());
        assertEquals("test", restAdapter.getRiskType());
    } catch (Exception e) {
        logger.error("testPrePopulateDCAEMSPolicyData", e);
        fail("testPrePopulateDCAEMSPolicyData failed due to: " + e);
    }
    logger.debug("testPrePopulateDCAEMSPolicyData: exit");
}