From 5008b80497d3256b724d54e0b26ad398f050571e Mon Sep 17 00:00:00 2001 From: Joanna Jeremicz Date: Mon, 23 Jul 2018 12:10:41 +0200 Subject: 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 --- .../org/onap/appc/licmgr/objects/LicenseModel.java | 21 +++++----- .../appc/licmgr/objects/LicenseModelBuilder.java | 45 ++++++++++++++++++++++ 2 files changed, 54 insertions(+), 12 deletions(-) create mode 100644 appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org/onap/appc/licmgr/objects/LicenseModelBuilder.java (limited to 'appc-dispatcher/appc-license-manager/appc-license-manager-api/src/main/java/org') 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); + } +} -- cgit 1.2.3-korg