From 4e5549ea37d5ab7d73cbd9b87640f05237253fa0 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 16 Apr 2019 11:44:18 -0400 Subject: Fix sonar issue in PdpStatusMessageHandler Change-Id: I389f61f9311bba35115a174c8526f897c98a3364 Issue-ID: POLICY-1542 Signed-off-by: Jim Hahn --- .../pap/main/comm/PdpStatusMessageHandler.java | 23 ++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java index b3bc1401..c0a78fa0 100644 --- a/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java +++ b/main/src/main/java/org/onap/policy/pap/main/comm/PdpStatusMessageHandler.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +24,7 @@ package org.onap.policy.pap.main.comm; import java.util.ArrayList; import java.util.List; import java.util.Optional; - +import org.apache.commons.lang3.builder.EqualsBuilder; import org.onap.policy.common.utils.services.Registry; import org.onap.policy.models.base.PfModelException; import org.onap.policy.models.pdp.concepts.Pdp; @@ -221,13 +222,19 @@ public class PdpStatusMessageHandler { } private boolean validatePdpDetails(final PdpStatus message, final PdpGroup pdpGroup, final PdpSubGroup subGroup, - final Pdp pdpInstanceDetails) { - - return message.getPdpGroup().equals(pdpGroup.getName()) - && message.getPdpSubgroup().equals(subGroup.getPdpType()) - && message.getState().equals(pdpInstanceDetails.getPdpState()) - && message.getSupportedPolicyTypes().containsAll(subGroup.getSupportedPolicyTypes()) - && message.getPdpType().equals(subGroup.getPdpType()); + final Pdp pdpInstanceDetails) { + + /* + * "EqualsBuilder" is a bit of a misnomer, as it uses containsAll() to check + * supported policy types. Nevertheless, it does the job and provides a convenient + * way to build a bunch of comparisons. + */ + return new EqualsBuilder().append(message.getPdpGroup(), pdpGroup.getName()) + .append(message.getPdpSubgroup(), subGroup.getPdpType()) + .append(message.getPdpType(), subGroup.getPdpType()) + .append(message.getState(), pdpInstanceDetails.getPdpState()) + .append(message.getSupportedPolicyTypes().containsAll(subGroup.getSupportedPolicyTypes()), true) + .build(); } private void updatePdpHealthStatus(final PdpStatus message, final PdpSubGroup pdpSubgroup, final Pdp pdpInstance, -- cgit 1.2.3-korg