diff options
author | Jakub Dudycz <jakub.dudycz@nokia.com> | 2018-03-12 13:53:32 +0100 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-03-12 18:37:55 +0000 |
commit | bbc49d304603dd4cccade55cc5f5711df3024592 (patch) | |
tree | 0d00ca59bd06b9bcd505d0ca2639ef41534cffcc /appc-config/appc-config-adaptor/provider/src | |
parent | f8f6d212382f458e1cb31081dad744e78f92e521 (diff) |
EncryptionTool unit tests
Improved code coverage + some test class refactor.
Change-Id: I7e3637c07b580acea383d1ccfd6a0608f69109fe
Issue-ID: APPC-722
Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'appc-config/appc-config-adaptor/provider/src')
-rw-r--r-- | appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java | 53 |
1 files changed, 38 insertions, 15 deletions
diff --git a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java index afa9137db..00e036ce3 100644 --- a/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java +++ b/appc-config/appc-config-adaptor/provider/src/test/java/org/onap/appc/ccadaptor/EncryptionToolTest.java @@ -1,9 +1,9 @@ /*-
- * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,29 +18,52 @@ * See the License for the specific language governing permissions and
* limitations under the License.
*
- * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.ccadaptor;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.BeforeClass;
import org.junit.Test;
public class EncryptionToolTest {
+ private static final String PLAIN_TEXT = "encrypt";
+ private static final String ENCRYPTED_TEXT = "enc:JjEZHlg7VQ==";
+ private static final String FAKE_ENCRYPTED_TEXT = "jsaASGou!na=e";
+
+ private static EncryptionTool encryptionTool;
+
+ @BeforeClass
+ public static void setup() {
+ encryptionTool = EncryptionTool.getInstance();
+ }
+
@Test
- public void testEncrypt() {
- EncryptionTool tool = EncryptionTool.getInstance();
- String value = tool.encrypt("encrypt");
- Assert.assertEquals("enc:JjEZHlg7VQ==", value);
+ public void should_return_null_when_given_null_to_encrypt() {
+ assertEquals(null, encryptionTool.encrypt(null));
}
@Test
- public void testDecrypt() {
- EncryptionTool tool = EncryptionTool.getInstance();
- String value = tool.decrypt("enc:JjEZHlg7VQ==");
- Assert.assertEquals("encrypt", value);
+ public void should_encrypt_given_string() {
+ assertEquals(ENCRYPTED_TEXT, encryptionTool.encrypt(PLAIN_TEXT));
}
+ @Test
+ public void should_return_null_when_given_null_to_decrypt() {
+ assertEquals(null, encryptionTool.decrypt(null));
+ }
+
+ @Test
+ public void should_return_same_string_when_given_unencrypted_string() {
+ assertEquals(FAKE_ENCRYPTED_TEXT, encryptionTool.decrypt(FAKE_ENCRYPTED_TEXT));
+ }
+
+ @Test
+ public void should_decrypt_given_string() {
+ assertEquals(PLAIN_TEXT, encryptionTool.decrypt(ENCRYPTED_TEXT));
+ }
}
\ No newline at end of file |