This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix WebResourceFactory support for sub resources
- Loading branch information
1 parent
d97ae75
commit 6e42500
Showing
3 changed files
with
73 additions
and
1 deletion.
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
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,46 @@ | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
|
||
import org.junit.Test; | ||
|
||
import io.reactivex.Single; | ||
|
||
public class SubResourceTest extends RxJerseyTest { | ||
|
||
@Test | ||
public void shouldReturnContentFromSubResourceWithoutPath() { | ||
SingleResource resource = resource(SingleResource.class); | ||
String subResourceId = resource.getSubResource("someId").getId().blockingGet(); | ||
|
||
assertEquals("someId", subResourceId); | ||
} | ||
|
||
@Test | ||
public void shouldReturnContentFromSubResourcePath() { | ||
SingleResource resource = resource(SingleResource.class); | ||
String attribute = resource.getSubResource("someId").getAttribute().blockingGet(); | ||
|
||
assertEquals("attribute", attribute); | ||
} | ||
|
||
@Path("/endpoint") | ||
public interface SingleResource { | ||
|
||
@Path("subresource/{id}") | ||
SingleSubResource getSubResource(@PathParam("id") String id); | ||
} | ||
|
||
public interface SingleSubResource { | ||
|
||
@GET | ||
Single<String> getId(); | ||
|
||
@GET | ||
@Path("attribute") | ||
Single<String> getAttribute(); | ||
|
||
} | ||
} |