aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandeep J <sandeejh@in.ibm.com>2018-07-18 17:49:43 +0530
committerTakamune Cho <tc012c@att.com>2018-07-19 19:22:14 +0000
commit6ac927687de08d03f749542ecb46b6f9e93625c8 (patch)
tree3c11b86a8c7508afbda5978cbab61ef0280cdec7
parente3228d1b699e89df911008f12b9494903ac9a0ef (diff)
added few test cases in StringHelperTest.java
added few test cases in stringhelpertest.java to increase code coverage Issue-ID: APPC-1086 Change-Id: I32d8648de64d1736685eb7c8a88017a2d3b7df98 Signed-off-by: Sandeep J <sandeejh@in.ibm.com>
-rw-r--r--appc-common/src/test/java/org/onap/appc/util/StringHelperTest.java39
1 files changed, 38 insertions, 1 deletions
diff --git a/appc-common/src/test/java/org/onap/appc/util/StringHelperTest.java b/appc-common/src/test/java/org/onap/appc/util/StringHelperTest.java
index 9053ee897..1022440b0 100644
--- a/appc-common/src/test/java/org/onap/appc/util/StringHelperTest.java
+++ b/appc-common/src/test/java/org/onap/appc/util/StringHelperTest.java
@@ -6,6 +6,8 @@
* ================================================================================
* Copyright (C) 2018 Nokia Solutions and Networks
* =============================================================================
+ * Modifications Copyright (C) 2018 IBM
+ * =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -32,11 +34,11 @@ import static org.junit.Assert.assertTrue;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;
@@ -53,6 +55,41 @@ public class StringHelperTest {
assertEquals(".*", StringHelper.convertToRegex(""));
assertEquals(".*", StringHelper.convertToRegex(" "));
}
+
+ @Test
+ public void convertToRegex_should_return_proper_regex_when_we_provide_a_proper_string_expression(){
+ String expected=".*test\\.jpg.test123\\.jpeg$";
+ assertEquals(expected,StringHelper.convertToRegex("*test.jpg+test123.jpeg"));
+ }
+
+ @Test
+ public void test_ResolveToType_with_null_as_input(){
+ assertNull(StringHelper.resolveToType(null));
+ }
+
+ @Test
+ public void test_ResolveToType_with_integer_as_input(){
+ Integer expected=-112;
+ assertEquals(expected,StringHelper.resolveToType("-112"));
+ }
+
+ @Test
+ public void test_ResolveToType_with_double_as_input(){
+ Double expected=-112.12;
+ assertEquals(expected,StringHelper.resolveToType("-112.12"));
+ }
+
+ @Test
+ public void test_ResolveToType_with_boolean_as_input(){
+ Boolean expected=true;
+ assertEquals(expected,StringHelper.resolveToType("true"));
+ }
+
+ @Test
+ public void test_ResolveToType_with_date_as_input(){
+ assertTrue(StringHelper.resolveToType("1994-11-05T08:15:30-05:00") instanceof Date);
+ }
+
@Test
public void getShortenedString_should_return_null_when_given_null(){