Browse code

Chore: make cli unit test more stable

Thomas Cataldo authored on 20/06/2019 06:22:04
Showing 1 changed files
... ...
@@ -49,10 +49,9 @@ public class OneDomainTenUsersCliTests {
49 49
 
50 50
 	public static final int USER_COUNT = 10;
51 51
 	private static String domainUid;
52
-	private static CliTestHelper testHelper	;
52
+	private static CliTestHelper testHelper;
53 53
 	private static CLIManager cli;
54 54
 
55
-
56 55
 	@BeforeClass
57 56
 	public static void beforeClass() throws Exception {
58 57
 		domainUid = "junit" + System.currentTimeMillis() + ".cli";
... ...
@@ -83,9 +82,9 @@ public class OneDomainTenUsersCliTests {
83 82
 		cli.processArgs("index", "shards");
84 83
 		String output = testHelper.outputAndReset();
85 84
 		assertNotNull(output);
86
-		int jsonArrayStart = output.indexOf("\n[");
87
-		assertTrue(jsonArrayStart > 0);
88
-		String justJson = output.substring(jsonArrayStart + 1);
85
+		int jsonArrayStart = output.indexOf("[ {");
86
+		assertTrue(jsonArrayStart >= 0);
87
+		String justJson = output.substring(jsonArrayStart);
89 88
 		JsonArray reparsedStats = new JsonArray(justJson);
90 89
 		assertTrue(reparsedStats.size() > 0);
91 90
 	}
... ...
@@ -181,7 +180,7 @@ public class OneDomainTenUsersCliTests {
181 180
 		LoginResponse response = authService.login("admin0@global.virt", "newpassword", "test");
182 181
 		assertTrue(response.status.equals(LoginResponse.Status.Ok));
183 182
 	}
184
-	
183
+
185 184
 	@Test
186 185
 	public void testDomainQuotaUpdate() {
187 186
 		cli.processArgs("user", "get", "--display", "quota email", domainUid);
... ...
@@ -192,15 +191,15 @@ public class OneDomainTenUsersCliTests {
192 191
 
193 192
 		cli.processArgs("user", "update", domainUid, "--quota", "2047");
194 193
 		output = testHelper.outputAndReset();
195
-		
194
+
196 195
 		cli.processArgs("user", "get", "--display", "quota", email);
197 196
 		output = testHelper.outputAndReset();
198
-		
197
+
199 198
 		List<JsonObject> entryObjects = Pattern.compile("\n").splitAsStream(output).filter(l -> l.startsWith("{"))
200 199
 				.map(l -> new JsonObject(l)).collect(Collectors.toList());
201 200
 		entryObjects.forEach(o -> assertEquals(2047, o.getInteger("quota").intValue()));
202 201
 	}
203
-	
202
+
204 203
 	@Test
205 204
 	public void testUserExport() {
206 205
 		cli.processArgs("user", "get", "--display", "quota email", domainUid);