4141
4242public class VaultClientTests {
4343 private static final String INVALID_EXCEPTION_THROWN = "Should not have thrown any exception" ;
44- private static final String EXCEPTION_NOT_THROWN = "Should have thrown an exception" ;
4544 private static VaultClient vaultClient ;
4645 private static String vaultID = null ;
4746 private static String clusterID = null ;
4847 private static String token = null ;
4948 private static String table = null ;
5049 private static String value = null ;
5150 private static String columnGroup = null ;
52- private static String apiKey = null ;
51+ private static String apiKey = "sky-ab123-abcd1234cdef1234abcd4321cdef4321" ;
5352 private static ArrayList <DetokenizeData > detokenizeData = null ;
5453 private static ArrayList <HashMap <String , Object >> insertValues = null ;
5554 private static ArrayList <HashMap <String , Object >> insertTokens = null ;
@@ -58,7 +57,7 @@ public class VaultClientTests {
5857 private static VaultConfig vaultConfig ;
5958
6059 @ BeforeClass
61- public static void setup () {
60+ public static void setup () throws SkyflowException {
6261 vaultID = "vault123" ;
6362 clusterID = "cluster123" ;
6463 token = "test_token" ;
@@ -72,80 +71,56 @@ public static void setup() {
7271 valueMap = new HashMap <>();
7372 tokenMap = new HashMap <>();
7473
75- Credentials credentials = new Credentials ();
76- credentials .setApiKey (apiKey );
77-
7874 vaultConfig = new VaultConfig ();
7975 vaultConfig .setVaultId (vaultID );
8076 vaultConfig .setClusterId (clusterID );
8177 vaultConfig .setEnv (Env .PROD );
78+
79+ Credentials credentials = new Credentials ();
80+ credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
81+ vaultConfig .setCredentials (credentials );
8282 vaultClient = new VaultClient (vaultConfig , credentials );
83+ vaultClient .setBearerToken ();
8384 }
8485
8586 @ Test
8687 public void testVaultClientGetRecordsAPI () {
8788 try {
88- Credentials credentials = new Credentials ();
89- credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
90- vaultConfig .setCredentials (credentials );
91- vaultClient = new VaultClient (vaultConfig , credentials );
92- vaultClient .setBearerToken ();
93-
9489 RecordsClient recordsClient = vaultClient .getRecordsApi ();
95- Assert .assertNotNull ("RecordsClient should not be null" , recordsClient );
90+ Assert .assertNotNull (recordsClient );
9691 } catch (Exception e ) {
97-
9892 e .printStackTrace ();
99- Assert .fail ("Should not have thrown any exception: " + e .getMessage ());
93+ Assert .fail (INVALID_EXCEPTION_THROWN + e .getMessage ());
10094 }
10195 }
10296
10397 @ Test
10498 public void testVaultClientDetectAPI () {
10599 try {
106- Credentials credentials = new Credentials ();
107- credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
108- vaultConfig .setCredentials (credentials );
109- vaultClient = new VaultClient (vaultConfig , credentials );
110- vaultClient .setBearerToken ();
111-
112100 FilesClient filesClient = vaultClient .getDetectFileAPi ();
113- Assert .assertNotNull ("FilesClient should not be null" , filesClient );
101+ Assert .assertNotNull (filesClient );
114102 } catch (Exception e ) {
115-
116103 e .printStackTrace ();
117- Assert .fail ("Should not have thrown any exception: " + e .getMessage ());
104+ Assert .fail (INVALID_EXCEPTION_THROWN + e .getMessage ());
118105 }
119106 }
120107
121108 @ Test
122109 public void testVaultClientDetectTextAPI () {
123110 try {
124- Credentials credentials = new Credentials ();
125- credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
126- vaultConfig .setCredentials (credentials );
127- vaultClient = new VaultClient (vaultConfig , credentials );
128- vaultClient .setBearerToken ();
129-
130111 StringsClient stringsClient = vaultClient .getDetectTextApi ();
131- Assert .assertNotNull ("StringsClient should not be null" , stringsClient );
112+ Assert .assertNotNull (stringsClient );
132113 } catch (Exception e ) {
133-
134114 e .printStackTrace ();
135- Assert .fail ("Should not have thrown any exception: " + e .getMessage ());
115+ Assert .fail (INVALID_EXCEPTION_THROWN + e .getMessage ());
136116 }
137117 }
138118
139119 @ Test
140120 public void testVaultClientGetTokensAPI () {
141121 try {
142- Credentials credentials = new Credentials ();
143- credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
144- vaultConfig .setCredentials (credentials );
145- vaultClient = new VaultClient (vaultConfig , credentials );
146- vaultClient .setBearerToken ();
147122 TokensClient tokensClient = vaultClient .getTokensApi ();
148- Assert .assertNotNull ("TokensClient should not be null" , tokensClient );
123+ Assert .assertNotNull (tokensClient );
149124 } catch (Exception e ) {
150125 Assert .fail (INVALID_EXCEPTION_THROWN );
151126 }
@@ -154,14 +129,8 @@ public void testVaultClientGetTokensAPI() {
154129 @ Test
155130 public void testVaultClientGetQueryAPI () {
156131 try {
157- Credentials credentials = new Credentials ();
158- credentials .setApiKey ("sky-ab123-abcd1234cdef1234abcd4321cdef4321" );
159- vaultConfig .setCredentials (credentials );
160-
161- vaultClient = new VaultClient (vaultConfig , credentials );
162- vaultClient .setBearerToken ();
163132 QueryClient queryClient = vaultClient .getQueryApi ();
164- Assert .assertNotNull ("QueryClient should not be null" , queryClient );
133+ Assert .assertNotNull (queryClient );
165134 } catch (Exception e ) {
166135 Assert .fail (INVALID_EXCEPTION_THROWN );
167136 }
0 commit comments