From 296fc9c47661e2b9e7d4e5293f1b25fc0cfc7d28 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 25 Jun 2021 17:29:21 -0400 Subject: Add name generator for PAP and PDPs Added a method that PAPs and PDPs can use to generate a unique name or identifier to be used in PAP-PDP messages. Issue-ID: POLICY-3410 Change-Id: I22b075b123f79ba05e0884f743296c4bc64842b9 Signed-off-by: Jim Hahn --- .../onap/policy/common/utils/network/NetworkUtilTest.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'utils/src/test/java/org') diff --git a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java index 4ae72842..4019ca79 100644 --- a/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java +++ b/utils/src/test/java/org/onap/policy/common/utils/network/NetworkUtilTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-utils * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package org.onap.policy.common.utils.network; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -91,6 +92,15 @@ public class NetworkUtilTest { } } + @Test + public void testGenUniqueName() { + String name = NetworkUtil.genUniqueName(LOCALHOST); + assertThat(name).isNotBlank().isNotEqualTo(LOCALHOST); + + // second call should generate a different value + assertThat(NetworkUtil.genUniqueName(LOCALHOST)).isNotEqualTo(name); + } + /** * Thread that accepts a connection on a socket. */ -- cgit 1.2.3-korg