diff options
author | 2018-09-25 19:08:51 +0000 | |
---|---|---|
committer | 2018-09-25 19:08:51 +0000 | |
commit | 1f1b81f57141704a3c596f602a1f224912180e72 (patch) | |
tree | 8bebace3a880899b75222846349787138485cd22 /ecomp-sdk/epsdk-aaf | |
parent | 4c56541410b1bbec78ae0f4247b7959c40783173 (diff) | |
parent | a62f756a10ba52a2cae064dfb1245f2c6a1a7e44 (diff) |
Merge "added test cases to ExternalAccessPermsT"
Diffstat (limited to 'ecomp-sdk/epsdk-aaf')
-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); + } } |