forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#36722 from leo-bogastry/add-error-messag…
…e-generate-web-links Add error message to quarkus-resteasy-reactive-links and improve documentation
- Loading branch information
Showing
10 changed files
with
206 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 2 additions & 12 deletions
14
...eployment/src/test/java/io/quarkus/resteasy/reactive/links/deployment/AbstractEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...ks/deployment/src/test/java/io/quarkus/resteasy/reactive/links/deployment/AbstractId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.resteasy.reactive.links.deployment; | ||
|
||
public abstract class AbstractId { | ||
|
||
private int id; | ||
|
||
public AbstractId() { | ||
} | ||
|
||
protected AbstractId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...java/io/quarkus/resteasy/reactive/links/deployment/RestLinksWithFailureInjectionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package io.quarkus.resteasy.reactive.links.deployment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.util.ExceptionUtil; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class RestLinksWithFailureInjectionTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot(jar -> jar.addClasses(TestRecordNoId.class, TestResourceNoId.class)).assertException(t -> { | ||
Throwable rootCause = ExceptionUtil.getRootCause(t); | ||
assertThat(rootCause).isInstanceOf(IllegalStateException.class) | ||
.hasMessageContaining("Cannot generate web links for the class " + | ||
"io.quarkus.resteasy.reactive.links.deployment.TestRecordNoId because is either " + | ||
"missing an `id` field or a field with an `@Id` annotation"); | ||
}); | ||
|
||
@Test | ||
void validationFailed() { | ||
// Should not be reached: verify | ||
assertTrue(false); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...eployment/src/test/java/io/quarkus/resteasy/reactive/links/deployment/TestRecordNoId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.quarkus.resteasy.reactive.links.deployment; | ||
|
||
public class TestRecordNoId { | ||
|
||
private String name; | ||
|
||
public TestRecordNoId() { | ||
} | ||
|
||
public TestRecordNoId(String value) { | ||
this.name = value; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...loyment/src/test/java/io/quarkus/resteasy/reactive/links/deployment/TestResourceNoId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.resteasy.reactive.links.deployment; | ||
|
||
import java.time.Duration; | ||
import java.util.Arrays; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import jakarta.ws.rs.*; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.reactive.common.util.RestMediaType; | ||
|
||
import io.quarkus.resteasy.reactive.links.InjectRestLinks; | ||
import io.quarkus.resteasy.reactive.links.RestLink; | ||
import io.quarkus.resteasy.reactive.links.RestLinkType; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/recordsNoId") | ||
@Produces({ MediaType.APPLICATION_JSON, RestMediaType.APPLICATION_HAL_JSON }) | ||
public class TestResourceNoId { | ||
|
||
private static final List<TestRecordNoId> RECORDS = new LinkedList<>(Arrays.asList( | ||
new TestRecordNoId("first_value"), | ||
new TestRecordNoId("second_value"))); | ||
|
||
@GET | ||
|
||
@RestLink(entityType = TestRecordNoId.class) | ||
@InjectRestLinks | ||
public Uni<List<TestRecordNoId>> getAll() { | ||
return Uni.createFrom().item(RECORDS).onItem().delayIt().by(Duration.ofMillis(100)); | ||
} | ||
|
||
@GET | ||
@Path("/by-name/{name}") | ||
@RestLink(entityType = TestRecordNoId.class) | ||
@InjectRestLinks(RestLinkType.INSTANCE) | ||
public TestRecordNoId getByNothing(@PathParam("name") String name) { | ||
return RECORDS.stream() | ||
.filter(record -> record.getName().equals(name)) | ||
.findFirst() | ||
.orElseThrow(NotFoundException::new); | ||
} | ||
} |