/*-\r
- * ============LICENSE_START=======================================================
- * ONAP : APPC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
* Copyright (C) 2017 Amdocs\r
* =============================================================================\r
* Licensed under the Apache License, Version 2.0 (the "License");\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
* \r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
* ============LICENSE_END=========================================================\r
*/\r
\r
package org.onap.appc.ccadaptor;\r
\r
-import org.junit.Assert;\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import org.junit.BeforeClass;\r
import org.junit.Test;\r
\r
public class EncryptionToolTest {\r
\r
+ private static final String PLAIN_TEXT = "encrypt";\r
+ private static final String ENCRYPTED_TEXT = "enc:JjEZHlg7VQ==";\r
+ private static final String FAKE_ENCRYPTED_TEXT = "jsaASGou!na=e";\r
+\r
+ private static EncryptionTool encryptionTool;\r
+\r
+ @BeforeClass\r
+ public static void setup() {\r
+ encryptionTool = EncryptionTool.getInstance();\r
+ }\r
+\r
@Test\r
- public void testEncrypt() {\r
- EncryptionTool tool = EncryptionTool.getInstance();\r
- String value = tool.encrypt("encrypt");\r
- Assert.assertEquals("enc:JjEZHlg7VQ==", value);\r
+ public void should_return_null_when_given_null_to_encrypt() {\r
+ assertEquals(null, encryptionTool.encrypt(null));\r
}\r
\r
@Test\r
- public void testDecrypt() {\r
- EncryptionTool tool = EncryptionTool.getInstance();\r
- String value = tool.decrypt("enc:JjEZHlg7VQ==");\r
- Assert.assertEquals("encrypt", value);\r
+ public void should_encrypt_given_string() {\r
+ assertEquals(ENCRYPTED_TEXT, encryptionTool.encrypt(PLAIN_TEXT));\r
}\r
\r
+ @Test\r
+ public void should_return_null_when_given_null_to_decrypt() {\r
+ assertEquals(null, encryptionTool.decrypt(null));\r
+ }\r
+\r
+ @Test\r
+ public void should_return_same_string_when_given_unencrypted_string() {\r
+ assertEquals(FAKE_ENCRYPTED_TEXT, encryptionTool.decrypt(FAKE_ENCRYPTED_TEXT));\r
+ }\r
+\r
+ @Test\r
+ public void should_decrypt_given_string() {\r
+ assertEquals(PLAIN_TEXT, encryptionTool.decrypt(ENCRYPTED_TEXT));\r
+ }\r
}
\ No newline at end of file