aboutsummaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-license-manager/appc-license-manager-api
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2018-07-23 12:10:41 +0200
committerTakamune Cho <tc012c@att.com>2018-08-09 18:01:41 +0000
commit5008b80497d3256b724d54e0b26ad398f050571e (patch)
tree2cba735259e1ff33d6d5b647d10de253403152c2 /appc-dispatcher/appc-license-manager/appc-license-manager-api
parentdc87c8cea2a6b6f68a8d7521db325fec4319b71a (diff)
Improve LicenseManagerImpl implementation
- Use STAX API for XML processing instead of parsing it manually - Rearrange code for clarity and testing - Adjust JUnits accordingly Issue-ID: APPC-1024 Change-Id: I9d655b581adb401b0c20bc29eda6a2bce1f2ef89 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'appc-dispatcher/appc-license-manager/appc-license-manager-api')
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModel.java21
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModelBuilder.java45
-rw-r--r--appc-dispatcher/appc-license-manager/appc-license-manager-api/src/test/java/org/onap/appc/licmgr/objects/TestLicenseModel.java8
3 files changed, 58 insertions, 16 deletions
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModel.java b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModel.java
index 070acdfd4..51257378e 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModel.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModel.java
@@ -6,6 +6,8 @@
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
+ * Modifications Copyright (C) 2018 Nokia
+ * =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -23,25 +25,20 @@
package org.onap.appc.licmgr.objects;
-public class LicenseModel {
+public final class LicenseModel {
- private String entitlementPoolUuid;
+ private final String entitlementPoolUuid;
+ private final String licenseKeyGroupUuid;
- private String licenseKeyGroupUuid;
+ public LicenseModel(String entitlementPoolUuid, String licenseKeyGroupUuid){
+ this.entitlementPoolUuid = entitlementPoolUuid;
+ this.licenseKeyGroupUuid = licenseKeyGroupUuid;
+ }
public String getEntitlementPoolUuid() {
return entitlementPoolUuid;
}
-
- public void setEntitlementPoolUuid(String entitlementPoolUuid) {
- this.entitlementPoolUuid = entitlementPoolUuid;
- }
-
public String getLicenseKeyGroupUuid() {
return licenseKeyGroupUuid;
}
-
- public void setLicenseKeyGroupUuid(String licenseKeyGroupUuid) {
- this.licenseKeyGroupUuid = licenseKeyGroupUuid;
- }
}
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModelBuilder.java b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModelBuilder.java
new file mode 100644
index 000000000..44f8a1383
--- /dev/null
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModelBuilder.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 Nokia
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.licmgr.objects;
+
+public class LicenseModelBuilder {
+ private String entitlementPoolUuid;
+ private String licenseKeyGroupUuid;
+
+ public LicenseModelBuilder setEntitlementPoolUuid(String entitlementPoolUuid){
+ this.entitlementPoolUuid = entitlementPoolUuid;
+ return this;
+ }
+
+ public LicenseModelBuilder setLicenseKeyGroupUuid(String licenseKeyGroupUuid){
+ this.licenseKeyGroupUuid = licenseKeyGroupUuid;
+ return this;
+ }
+
+ public boolean isReady() {
+ return entitlementPoolUuid != null && licenseKeyGroupUuid != null;
+ }
+
+ public LicenseModel build(){
+ return new LicenseModel(entitlementPoolUuid, licenseKeyGroupUuid);
+ }
+}
diff --git a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/test/java/org/onap/appc/licmgr/objects/TestLicenseModel.java b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/test/java/org/onap/appc/licmgr/objects/TestLicenseModel.java
index bcb862676..9e1d8860f 100644
--- a/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/test/java/org/onap/appc/licmgr/objects/TestLicenseModel.java
+++ b/appc-dispatcher/appc-license-manager/appc-license-manager-api/src/test/java/org/onap/appc/licmgr/objects/TestLicenseModel.java
@@ -3,7 +3,9 @@
* ONAP : APPC
* ================================================================================
* Copyright 2018 TechMahindra
-*=================================================================================
+* ================================================================================
+* Modifications Copyright (C) 2018 Nokia
+* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -28,19 +30,17 @@ public class TestLicenseModel {
@Before
public void setUp() {
- licenseModel = new LicenseModel();
+ licenseModel = new LicenseModel("EntitlementPoolUuid", "LicenseKeyGroupUuid");
}
@Test
public void testGetEntitlementPoolUuid() {
- licenseModel.setEntitlementPoolUuid("EntitlementPoolUuid");
Assert.assertNotNull(licenseModel.getEntitlementPoolUuid());
Assert.assertEquals(licenseModel.getEntitlementPoolUuid(), "EntitlementPoolUuid");
}
@Test
public void testGetLicenseKeyGroupUuid() {
- licenseModel.setLicenseKeyGroupUuid("LicenseKeyGroupUuid");
Assert.assertNotNull(licenseModel.getLicenseKeyGroupUuid());
Assert.assertEquals(licenseModel.getLicenseKeyGroupUuid(), "LicenseKeyGroupUuid");
}