+
+ @Test
+ public void retrieveLicenseModel_shouldReturnLicenseModelWithNullValues_whenXmlIsMalformed() {
+
+ // GIVEN
+ String malformedXml = "xyz";
+
+ Map<String, String> licenseModelData = new HashMap<>();
+ licenseModelData.put(ARTIFACT_CONTENT.name(), malformedXml);
+ given(licenseDataAccessService.retrieveLicenseModelData(VNF_TYPE, VNF_VERSION))
+ .willReturn(licenseModelData);
+
+ // WHEN
+ licenseManager.setDAService(licenseDataAccessService);
+ LicenseModel licenseModel = licenseManager.retrieveLicenseModel(VNF_TYPE, VNF_VERSION);
+
+ // THEN
+ assertNull(licenseModel.getEntitlementPoolUuid());
+ assertNull(licenseModel.getLicenseKeyGroupUuid());
+ }
+
+ @Test
+ public void retrieveLicenseModel_shouldReturnCorrectLicenseModel_whenCorrectXmlExists() {
+
+ // GIVEN
+ String expectedEntitlementPool = "default_entitlement_pool";
+ String expectedKeyGroup = "default_key_group";
+
+ String correctlyFormedXml = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<parent>\n"
+ + "<entitlement-pool-uuid>%s</entitlement-pool-uuid>\n"
+ + "<license-key-group-uuid>%s</license-key-group-uuid>\n"
+ + "</parent>", expectedEntitlementPool, expectedKeyGroup);
+
+ Map<String, String> licenseModelData = new HashMap<>();
+ licenseModelData.put(ARTIFACT_CONTENT.name(), correctlyFormedXml);
+ given(licenseDataAccessService.retrieveLicenseModelData(VNF_TYPE, VNF_VERSION))
+ .willReturn(licenseModelData);
+
+ // WHEN
+ licenseManager.setDAService(licenseDataAccessService);
+ LicenseModel licenseModel = licenseManager.retrieveLicenseModel(VNF_TYPE, VNF_VERSION);
+
+ // THEN
+ assertEquals(expectedEntitlementPool, licenseModel.getEntitlementPoolUuid());
+ assertEquals(expectedKeyGroup, licenseModel.getLicenseKeyGroupUuid());
+ }