diff options
author | Sandeep J <sandeejh@in.ibm.com> | 2018-09-24 18:14:03 +0530 |
---|---|---|
committer | Sandeep J <sandeejh@in.ibm.com> | 2018-09-24 18:15:58 +0530 |
commit | a62f756a10ba52a2cae064dfb1245f2c6a1a7e44 (patch) | |
tree | 13975c07ab401b58fb689cb03f80c09d679a21e0 /ecomp-sdk/epsdk-aaf/src/test/java | |
parent | f6e512bb85978cd8320ee4ea2ed4da234fa0d10b (diff) |
added test cases to ExternalAccessPermsT
to increase code coverage
Issue-ID: PORTAL-273
Change-Id: If5cca86d90c87ac9467c98c4aa19825e05ac576b
Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
Diffstat (limited to 'ecomp-sdk/epsdk-aaf/src/test/java')
-rw-r--r-- | ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java | 99 |
1 files changed, 62 insertions, 37 deletions
diff --git a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java index 0f3a65a5..b118811b 100644 --- a/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java +++ b/ecomp-sdk/epsdk-aaf/src/test/java/org/onap/portalsdk/external/authorization/domain/ExternalAccessPermsTest.java @@ -4,7 +4,8 @@ * =================================================================== * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * =================================================================== - * + * Modifications Copyright (C) 2018 IBM. + * =================================================================== * Unless otherwise specified, all software contained herein is licensed * under the Apache License, Version 2.0 (the "License"); * you may not use this software except in compliance with the License. @@ -38,6 +39,7 @@ package org.onap.portalsdk.external.authorization.domain; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -46,41 +48,64 @@ import org.junit.Test; public class ExternalAccessPermsTest { - public ExternalAccessPerms mockExternalAccessPermsTest() { - ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms(); - mockExtPermsTest.setAction("*"); - mockExtPermsTest.setDescription("test_name"); - mockExtPermsTest.setType("test_type"); - mockExtPermsTest.setInstance("test_instance"); - return mockExtPermsTest; - } + public ExternalAccessPerms mockExternalAccessPermsTest() { + ExternalAccessPerms mockExtPermsTest = new ExternalAccessPerms(); + mockExtPermsTest.setAction("*"); + mockExtPermsTest.setDescription("test_name"); + mockExtPermsTest.setType("test_type"); + mockExtPermsTest.setInstance("test_instance"); + return mockExtPermsTest; + } - @Test - public void externalAccessPermsTest() { - List<String> roles = new ArrayList<>(); - roles.add("test_role"); - roles.add("test_role2"); - ExternalAccessPerms extPermsDetailTest = new ExternalAccessPerms(); - ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*"); - ExternalAccessPerms extPermsDetailTest3 = new ExternalAccessPerms("test_type", "test_instance", "*", - "test_name"); - extPermsDetailTest.setAction("*"); - extPermsDetailTest.setDescription("test_name"); - extPermsDetailTest.setType("test_type"); - extPermsDetailTest.setInstance("test_instance"); - assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsTest().getAction()); - assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsTest().getType()); - assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsTest().getInstance()); - assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsTest().getDescription()); - assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsTest().getAction()); - assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsTest().getType()); - assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsTest().getInstance()); - assertEquals(null, extPermsDetailTest2.getDescription()); - assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsTest().getAction()); - assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsTest().getType()); - assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsTest().getInstance()); - assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsTest().getDescription()); - assertEquals(true, new ExternalAccessPerms("test_type", "test_instance", "*", "test_name") - .equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name"))); - } + @Test + public void externalAccessPermsTest() { + List<String> roles = new ArrayList<>(); + roles.add("test_role"); + roles.add("test_role2"); + ExternalAccessPerms extPermsDetailTest = new ExternalAccessPerms(); + ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*"); + ExternalAccessPerms extPermsDetailTest3 = new ExternalAccessPerms("test_type", "test_instance", "*", + "test_name"); + extPermsDetailTest.setAction("*"); + extPermsDetailTest.setDescription("test_name"); + extPermsDetailTest.setType("test_type"); + extPermsDetailTest.setInstance("test_instance"); + assertEquals(extPermsDetailTest.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(extPermsDetailTest.getDescription(), mockExternalAccessPermsTest().getDescription()); + assertEquals(extPermsDetailTest2.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest2.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest2.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(null, extPermsDetailTest2.getDescription()); + assertEquals(extPermsDetailTest3.getAction(), mockExternalAccessPermsTest().getAction()); + assertEquals(extPermsDetailTest3.getType(), mockExternalAccessPermsTest().getType()); + assertEquals(extPermsDetailTest3.getInstance(), mockExternalAccessPermsTest().getInstance()); + assertEquals(extPermsDetailTest3.getDescription(), mockExternalAccessPermsTest().getDescription()); + assertEquals(true, new ExternalAccessPerms("test_type", "test_instance", "*", "test_name") + .equals(new ExternalAccessPerms("test_type", "test_instance", "*", "test_name"))); + } + + @Test + public void testCompareTo() + { + ExternalAccessPerms extPermsDetailTest1 = new ExternalAccessPerms("test_type", "test_instance", "*"); + ExternalAccessPerms extPermsDetailTest2 = new ExternalAccessPerms("test_type", "test_instance", "*", + "test_name"); + extPermsDetailTest1.setInstance("test_instance"); + extPermsDetailTest2.setInstance("test_instance"); + int result= extPermsDetailTest1.compareTo(extPermsDetailTest2); + assertEquals(0, result); + } + + @Test + public void testHashCode() + { + ExternalAccessPerms extPermsDetailTest = new ExternalAccessPerms(); + extPermsDetailTest.setAction("*"); + extPermsDetailTest.setDescription("test_name"); + extPermsDetailTest.setType("test_type"); + extPermsDetailTest.setInstance("test_instance"); + assertTrue((Integer)extPermsDetailTest.hashCode() instanceof Integer); + } } |