@Test
public void testScenarioWhenDeafultConfigIncorrect() throws IOException {

    //Verify error in validating a leaf which is not present in the schema registry
    List<String> cap = new ArrayList<>();
    cap.add("capability1-adapter2");
    cap.add("capability2-adapter2");
    byte[] m_defaultConfigIncorrect = IOUtils.toByteArray(getClass().getResourceAsStream("/model/default-config-incorrect.xml"));
    DeviceAdapter adapter = AdapterBuilder.createAdapterBuilder()
            .setDeviceAdapterId(new DeviceAdapterId("DPU", "1.0", "4LT", "VENDOR"))
            .setModuleStream(getStreamMap())
            .setCaps(cap)
            .setDeviceXml(m_inputStream)
            .setDefaultxmlBytes(m_defaultConfigIncorrect)
            .setSupportedDeviations(CommonFileUtil.getAdapterDeviationsFromFile(getInputStream("model/supported-deviations.txt")))
            .setSupportedFeatures(CommonFileUtil.getAdapterFeaturesFromFile(getInputStream("model/supported-features.txt")))
            .build();
    adapter.setStdAdapterIntVersion("2.0");
    try {
        m_adapterManager.deploy(m_stdAdapterv2, m_subSystem, getClass(), m_deviceInterface);
        m_adapterManager.deploy(adapter, m_subSystem, getClass(), m_deviceInterface);
    } catch (Exception e) {
        assertEquals("Error while deploying adapter", e.getMessage());
        String message = e.getCause().getMessage();
        assertTrue(message.contains("ValidationException"));
        assertTrue(message.contains("errorMessage=An unexpected element leaf-not-present is present"));
        assertTrue(message.contains("errorTag=unknown-element"));
        assertTrue(message.contains("errorSeverity=error"));
        assertTrue(message.contains("errorType=application"));
    }
    m_defaultConfigIncorrect = IOUtils.toByteArray(getClass().getResourceAsStream("/model/default-config-incorrect2.xml"));
    adapter = AdapterBuilder.createAdapterBuilder()
            .setDeviceAdapterId(new DeviceAdapterId("DPU", "1.0", "4LT", "VENDOR"))
            .setModuleStream(getStreamMap())
            .setCaps(cap)
            .setDeviceXml(m_inputStream)
            .setDefaultxmlBytes(m_defaultConfigIncorrect)
            .setSupportedDeviations(CommonFileUtil.getAdapterDeviationsFromFile(getInputStream("model/supported-deviations.txt")))
            .setSupportedFeatures(CommonFileUtil.getAdapterFeaturesFromFile(getInputStream("model/supported-features.txt")))
            .build();
    adapter.setStdAdapterIntVersion("2.0");
    try {
        m_adapterManager.deploy(adapter, m_subSystem, getClass(), m_deviceInterface);
    } catch (Exception e) {
        assertEquals("Error while deploying adapter", e.getMessage());
        String message = e.getCause().getMessage();
        assertTrue(message.contains("Failed to parse default-config.xml from the adapter"));
        assertTrue(message.contains("The element type \"if:leaf-not-present\" must be terminated by the matching end-tag"));
    }
}