@@ -122,7 +122,7 @@ public void testTaskStoreMethodsSanityTest() throws Exception {
122122 Task saved = getTaskFromTaskStore (task .getId ());
123123 assertEquals (task .getId (), saved .getId ());
124124 assertEquals (task .getContextId (), saved .getContextId ());
125- assertEquals (task .getStatus (), saved .getStatus ());
125+ assertEquals (task .getStatus (). state () , saved .getStatus (). state ());
126126
127127 deleteTaskInTaskStore (task .getId ());
128128 Task saved2 = getTaskFromTaskStore (task .getId ());
@@ -160,7 +160,6 @@ private void testGetTask(String mediaType) throws Exception {
160160 assertEquals ("session-xyz" , response .getResult ().getContextId ());
161161 assertEquals (TaskState .SUBMITTED , response .getResult ().getStatus ().state ());
162162 assertNull (response .getError ());
163- } catch (Exception e ) {
164163 } finally {
165164 deleteTaskInTaskStore (MINIMAL_TASK .getId ());
166165 }
@@ -971,12 +970,13 @@ protected void enqueueEventOnServer(Event event) throws Exception {
971970 .build ();
972971 HttpRequest request = HttpRequest .newBuilder ()
973972 .uri (URI .create ("http://localhost:" + serverPort + "/" + path ))
973+ .header ("Content-Type" , APPLICATION_JSON )
974974 .POST (HttpRequest .BodyPublishers .ofString (Utils .OBJECT_MAPPER .writeValueAsString (event )))
975975 .build ();
976976
977977 HttpResponse <String > response = client .send (request , HttpResponse .BodyHandlers .ofString (StandardCharsets .UTF_8 ));
978978 if (response .statusCode () != 200 ) {
979- throw new RuntimeException (response .statusCode () + ": Deleting task failed!" + response .body ());
979+ throw new RuntimeException (response .statusCode () + ": Queueing event failed!" + response .body ());
980980 }
981981 }
982982
@@ -986,15 +986,22 @@ private CompletableFuture<Void> awaitStreamingSubscription() {
986986
987987 return CompletableFuture .runAsync (() -> {
988988 try {
989- while (true ) {
989+ boolean done = false ;
990+ long end = System .currentTimeMillis () + 15000 ;
991+ while (System .currentTimeMillis () < end ) {
990992 int count = getStreamingSubscribedCount ();
991993 if (count > initialCount .get ()) {
994+ done = true ;
992995 break ;
993996 }
994997 Thread .sleep (500 );
995998 }
999+ if (!done ) {
1000+ throw new RuntimeException ("Timed out waiting for subscription" );
1001+ }
9961002 } catch (InterruptedException e ) {
9971003 Thread .currentThread ().interrupt ();
1004+ throw new RuntimeException ("Interrupted" );
9981005 }
9991006 });
10001007 }
@@ -1010,8 +1017,7 @@ private int getStreamingSubscribedCount() {
10101017 try {
10111018 HttpResponse <String > response = client .send (request , HttpResponse .BodyHandlers .ofString (StandardCharsets .UTF_8 ));
10121019 String body = response .body ().trim ();
1013- System .out .println (body );
1014- return Integer .valueOf (body );
1020+ return Integer .parseInt (body );
10151021 } catch (IOException | InterruptedException e ) {
10161022 throw new RuntimeException (e );
10171023 }
0 commit comments