File tree Expand file tree Collapse file tree
coverage-report/src/test/java/org/jooby/ws
test/java/org/jooby/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,14 +27,6 @@ public class WebSocketPauseResumeFeature extends ServerFeature {
2727 {
2828 ws ("/ws" , ws -> {
2929 CountDownLatch latch = new CountDownLatch (1 );
30- ws .onMessage (message -> {
31-
32- ws .send ("=" + message .value (), () -> {
33- latch .await ();
34- ws .close ();
35- });
36-
37- });
3830
3931 ws .pause ();
4032 // 2nd ignored
@@ -46,6 +38,16 @@ public class WebSocketPauseResumeFeature extends ServerFeature {
4638 ws .resume ();
4739 latch .countDown ();
4840 }, 1 , TimeUnit .SECONDS );
41+
42+ ws .onMessage (message -> {
43+
44+ ws .send ("=" + message .value (), () -> {
45+ latch .await ();
46+ ws .close ();
47+ });
48+
49+ });
50+
4951 });
5052
5153 }
Original file line number Diff line number Diff line change 3131
3232/**
3333 * <p>
34- * A type safe {@link Mutant} useful for reading parameters and headers. It let you retrieve a
35- * HTTP value: <code>param</code> or <code>header</code> in a type safe manner.
34+ * A type safe {@link Mutant} useful for reading parameters and headers.
3635 * </p>
3736 *
3837 * <pre>
38+ * // str param
39+ * String value = request.param("str").value();
40+ *
41+ * // optional str
42+ * String value = request.param("str").toOptional().orElse("defs");
43+ *
3944 * // int param
40- * int value = request.param("some").getInt ();
45+ * int value = request.param("some").intValue ();
4146 *
4247 * // optional int param
43- * Optional{@literal <}Integer{@literal >} value = request.param("some").getOptional (Integer.class);
48+ * Optional{@literal <}Integer{@literal >} value = request.param("some").toOptional (Integer.class);
4449
4550 * // list param
46- * List{@literal <}String{@literal >} values = request.param("some").getList (String.class);
51+ * List{@literal <}String{@literal >} values = request.param("some").toList (String.class);
4752 *
4853 * // file upload
49- * Upload upload = request.param("file").get (Upload.class);
54+ * Upload upload = request.param("file").to (Upload.class);
5055 * </pre>
5156 *
5257 * @author edgar
@@ -153,6 +158,13 @@ default <T extends Comparable<T>> SortedSet<T> toSortedSet(@Nonnull final Class<
153158 ));
154159 }
155160
161+ /**
162+ * @return An optional string value.
163+ */
164+ default Optional <String > toOptional () {
165+ return toOptional (String .class );
166+ }
167+
156168 /**
157169 * @param type The optional type.
158170 * @param <T> Optional type.
Original file line number Diff line number Diff line change @@ -461,7 +461,11 @@ public void asStringSortedSet() throws Exception {
461461 public void asOptionalString () throws Exception {
462462 assertEquals (Optional .empty (), newMutant ((String ) null ).toOptional (String .class ));
463463
464+ assertEquals (Optional .empty (), newMutant ((String ) null ).toOptional ());
465+
464466 assertEquals (Optional .of ("A" ), newMutant ("A" ).toOptional (String .class ));
467+
468+ assertEquals (Optional .of ("A" ), newMutant ("A" ).toOptional ());
465469 }
466470
467471 @ Test
You can’t perform that action at this time.
0 commit comments