Skip to content

Commit

Permalink
rm some methods and changed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yelouarti committed Dec 20, 2024
1 parent 01f3a4a commit 2fc1d0e
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 207 deletions.
68 changes: 34 additions & 34 deletions src/main/java/de/kamillionlabs/hateoflux/http/HalListResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,19 @@ public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> ok(
return new HalListResponse<>(body, Mono.just(HttpStatus.OK), null);
}

/**
* Creates a {@link HalListResponse} with {@link HttpStatus#OK}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code OK} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> ok() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.OK), null);
}

/**
* Creates a {@link HalListResponse} with a body and {@link HttpStatus#CREATED}.
*
Expand All @@ -192,6 +205,19 @@ public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> creat
return new HalListResponse<>(body, Mono.just(HttpStatus.CREATED), null);
}

/**
* Creates a {@link HalListResponse} with {@link HttpStatus#CREATED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code CREATED} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> created() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.CREATED), null);
}

/**
* Creates a {@link HalListResponse} with a body and {@link HttpStatus#ACCEPTED}.
*
Expand All @@ -213,29 +239,29 @@ public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> accep
}

/**
* Creates a {@link HalListResponse} with no body and {@link HttpStatus#NO_CONTENT}.
* Creates a {@link HalListResponse} with {@link HttpStatus#ACCEPTED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code NO_CONTENT} status
* @return a {@link HalListResponse} with {@code ACCEPTED} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> noContent() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.NO_CONTENT), null);
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> accepted() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.ACCEPTED), null);
}

/**
* Creates a {@link HalListResponse} with no body and {@link HttpStatus#BAD_REQUEST}.
* Creates a {@link HalListResponse} with no body and {@link HttpStatus#NO_CONTENT}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code BAD_REQUEST} status
* @return a {@link HalListResponse} with {@code NO_CONTENT} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> badRequest() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.BAD_REQUEST), null);
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> noContent() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.NO_CONTENT), null);
}

/**
Expand All @@ -250,30 +276,4 @@ public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> badRe
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> notFound() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.NOT_FOUND), null);
}

/**
* Creates a {@link HalListResponse} with no body and {@link HttpStatus#FORBIDDEN}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code FORBIDDEN} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> forbidden() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.FORBIDDEN), null);
}

/**
* Creates a {@link HalListResponse} with no body and {@link HttpStatus#UNAUTHORIZED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalListResponse} with {@code UNAUTHORIZED} status
*/
public static <ResourceT, EmbeddedT> HalListResponse<ResourceT, EmbeddedT> unauthorized() {
return new HalListResponse<>(Mono.empty(), Mono.just(HttpStatus.UNAUTHORIZED), null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
* {@link HalResourceWrapper}/li>
* <li><strong>{@link HalMultiResourceResponse}</strong>: Use when your endpoint returns <b>multiple</b>
* {@link HalResourceWrapper}</li>
* <li><strong>{@link HalListResponse}</strong>: Use when your endpoint returns a single {@link HalListWrapper}</li>
* <li><strong>{@link HalMultiResourceResponse}</strong>: Use when your endpoint returns a single
* {@link HalListWrapper}</li>
* </ul>
*
* @param <ResourceT>
Expand Down Expand Up @@ -166,6 +167,19 @@ public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, Embedde
return new HalMultiResourceResponse<>(body, HttpStatus.OK, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with {@link HttpStatus#OK}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code OK} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> ok() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.OK, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with the given HAL resource body and {@link HttpStatus#CREATED}.
*
Expand All @@ -187,6 +201,19 @@ public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, Embedde
return new HalMultiResourceResponse<>(body, HttpStatus.CREATED, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with {@link HttpStatus#CREATED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code CREATED} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> created() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.CREATED, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with the given HAL resource body and {@link HttpStatus#ACCEPTED}.
*
Expand All @@ -209,29 +236,29 @@ public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, Embedde
}

/**
* Creates a {@link HalMultiResourceResponse} with no body and {@link HttpStatus#NO_CONTENT}.
* Creates a {@link HalMultiResourceResponse} with {@link HttpStatus#ACCEPTED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code NO_CONTENT} status
* @return a {@link HalMultiResourceResponse} with {@code ACCEPTED} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> noContent() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.NO_CONTENT, null);
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> accepted() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.ACCEPTED, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with no body and {@link HttpStatus#BAD_REQUEST}.
* Creates a {@link HalMultiResourceResponse} with no body and {@link HttpStatus#NO_CONTENT}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code BAD_REQUEST} status
* @return a {@link HalMultiResourceResponse} with {@code NO_CONTENT} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> badRequest() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.BAD_REQUEST, null);
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> noContent() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.NO_CONTENT, null);
}

/**
Expand All @@ -246,30 +273,4 @@ public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, Embedde
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> notFound() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.NOT_FOUND, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with no body and {@link HttpStatus#FORBIDDEN}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code FORBIDDEN} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> forbidden() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.FORBIDDEN, null);
}

/**
* Creates a {@link HalMultiResourceResponse} with no body and {@link HttpStatus#UNAUTHORIZED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalMultiResourceResponse} with {@code UNAUTHORIZED} status
*/
public static <ResourceT, EmbeddedT> HalMultiResourceResponse<ResourceT, EmbeddedT> unauthorized() {
return new HalMultiResourceResponse<>(Flux.empty(), HttpStatus.UNAUTHORIZED, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
* {@link HalResourceWrapper}/li>
* <li><strong>{@link HalMultiResourceResponse}</strong>: Use when your endpoint returns <b>multiple</b>
* {@link HalResourceWrapper}</li>
* <li><strong>{@link HalListResponse}</strong>: Use when your endpoint returns a single {@link HalListWrapper}</li>
* <li><strong>{@link HalResourceResponse}</strong>: Use when your endpoint returns a single {@link HalListWrapper}
* </li>
* </ul>
*
* @param <ResourceT>
Expand Down Expand Up @@ -173,6 +174,19 @@ public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> o
return new HalResourceResponse<>(body, Mono.just(HttpStatus.OK), null);
}

/**
* Creates a {@link HalResourceResponse} with {@link HttpStatus#OK}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalResourceResponse} with {@code OK} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> ok() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.OK), null);
}

/**
* Creates a {@code HalResourceResponse} with a body and {@link HttpStatus#CREATED}.
*
Expand All @@ -193,6 +207,19 @@ public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> c
return new HalResourceResponse<>(body, Mono.just(HttpStatus.CREATED), null);
}

/**
* Creates a {@link HalResourceResponse} with {@link HttpStatus#CREATED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@link HalResourceResponse} with {@code CREATED} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> created() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.CREATED), null);
}

/**
* Creates a {@code HalResourceResponse} with a body and {@link HttpStatus#ACCEPTED}.
*
Expand All @@ -214,29 +241,29 @@ public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> a
}

/**
* Creates a {@code HalResourceResponse} with no body and {@link HttpStatus#NO_CONTENT}.
* Creates a {@link HalResourceResponse} with {@link HttpStatus#ACCEPTED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@code HalResourceResponse} with {@code NO_CONTENT} status
* @return a {@link HalResourceResponse} with {@code ACCEPTED} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> noContent() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.NO_CONTENT), null);
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> accepted() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.ACCEPTED), null);
}

/**
* Creates a {@code HalResourceResponse} with no body and {@link HttpStatus#BAD_REQUEST}.
* Creates a {@code HalResourceResponse} with no body and {@link HttpStatus#NO_CONTENT}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@code HalResourceResponse} with {@code BAD_REQUEST} status
* @return a {@code HalResourceResponse} with {@code NO_CONTENT} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> badRequest() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.BAD_REQUEST), null);
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> noContent() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.NO_CONTENT), null);
}

/**
Expand All @@ -251,30 +278,4 @@ public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> b
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> notFound() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.NOT_FOUND), null);
}

/**
* Creates a {@code HalResourceResponse} with no body and {@link HttpStatus#FORBIDDEN}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@code HalResourceResponse} with {@code FORBIDDEN} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> forbidden() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.FORBIDDEN), null);
}

/**
* Creates a {@code HalResourceResponse} with no body and {@link HttpStatus#UNAUTHORIZED}.
*
* @param <ResourceT>
* the resource type
* @param <EmbeddedT>
* the embedded resource type
* @return a {@code HalResourceResponse} with {@code UNAUTHORIZED} status
*/
public static <ResourceT, EmbeddedT> HalResourceResponse<ResourceT, EmbeddedT> unauthorized() {
return new HalResourceResponse<>(Mono.empty(), Mono.just(HttpStatus.UNAUTHORIZED), null);
}
}
Loading

0 comments on commit 2fc1d0e

Please sign in to comment.