Skip to content

Commit

Permalink
Add the id to this JSON and delete 2 tests, and add a new test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpan123 committed Aug 6, 2020
1 parent 9e280ae commit 996d904
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/amihaiemil/docker/RtContainers.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ URI baseUri() {
@Override
public Container get(final String containerId) {
return new RtContainer(
Json.createObjectBuilder().build(),
Json.createObjectBuilder()
.add("Id", containerId)
.build(),
this.client,
URI.create(
this.baseUri.toString() + "/" + containerId
Expand Down
43 changes: 14 additions & 29 deletions src/test/java/com/amihaiemil/docker/RtContainersTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -513,34 +513,19 @@ public void createsContainerWithId() throws Exception {
* @throws Exception If something goes wrong.
*/
@Test
public void getContainerWithIdStartsWithNotFound() throws Exception {
new ListedContainers(
new AssertRequest(
new Response(
HttpStatus.SC_NO_CONTENT,
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
)
),
URI.create("http://localhost/test"),
Mockito.mock(Docker.class)
).get("df2419f4").start();
}

/**
* RtContainers.get() returns an RtContainer with the container id.
* @throws Exception If something goes wrong.
*/
@Test
public void getContainerWithIdStopWithNotFound() throws Exception {
new ListedContainers(
new AssertRequest(
new Response(
HttpStatus.SC_NO_CONTENT,
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
)
),
URI.create("http://localhost/test"),
Mockito.mock(Docker.class)
).get("df2419f4").stop();
public void getContainerWithId() throws Exception {
MatcherAssert.assertThat(
new ListedContainers(
new AssertRequest(
new Response(
HttpStatus.SC_OK,
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
)
),
URI.create("http://localhost/test"),
Mockito.mock(Docker.class)
).get("df2419f4").getString("Id"),
Matchers.is("df2419f4")
);
}
}

0 comments on commit 996d904

Please sign in to comment.