Merge from ECOMP's repository
[vid.git] / vid-app-common / src / test / java / org / onap / vid / aai / util / CacheProviderTest.java
1 package org.onap.vid.aai.util;
2
3 import org.testng.annotations.DataProvider;
4 import org.testng.annotations.Test;
5
6 import java.util.Arrays;
7 import java.util.List;
8
9 import static org.hamcrest.Matchers.is;
10 import static org.hamcrest.MatcherAssert.assertThat;
11 import static org.onap.vid.aai.util.CacheProvider.compileKey;
12 import static org.onap.vid.aai.util.CacheProvider.decompileKey;
13
14 public class CacheProviderTest {
15     @Test(dataProvider = "aaiClientCompileDecompileKeySameData")
16     public void compileDecompileKeySameTest(List<String> args) {
17         assertThat(decompileKey(compileKey(args)), is(args.toArray()));
18     }
19
20     @Test(dataProvider = "aaiClientCompileDecompileKeyDifferentData")
21     public void compileDecompileKeyDifferentTest(List<String> expectedResult, List<String> args) {
22         assertThat(decompileKey(compileKey(args)), is(expectedResult.toArray()));
23     }
24
25     @DataProvider
26     public static Object[][] aaiClientCompileDecompileKeySameData() {
27         return new Object[][] {
28                 {Arrays.asList( "a", "b", "c")},
29                 {Arrays.asList("a")},
30                 {Arrays.asList("a!", "@#?b")},
31                 {Arrays.asList("a", "", "c")}
32         };
33     }
34
35     @DataProvider
36     public static Object[][] aaiClientCompileDecompileKeyDifferentData() {
37         return new Object[][] {
38                 {Arrays.asList("a", "", "c"), Arrays.asList("a", null, "c")}
39         };
40     }
41 }