Skip to content

Commit 996d904

Browse files
committed
Add the id to this JSON and delete 2 tests, and add a new test.
1 parent 9e280ae commit 996d904

File tree

2 files changed

+17
-30
lines changed

2 files changed

+17
-30
lines changed

src/main/java/com/amihaiemil/docker/RtContainers.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ URI baseUri() {
168168
@Override
169169
public Container get(final String containerId) {
170170
return new RtContainer(
171-
Json.createObjectBuilder().build(),
171+
Json.createObjectBuilder()
172+
.add("Id", containerId)
173+
.build(),
172174
this.client,
173175
URI.create(
174176
this.baseUri.toString() + "/" + containerId

src/test/java/com/amihaiemil/docker/RtContainersTestCase.java

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -513,34 +513,19 @@ public void createsContainerWithId() throws Exception {
513513
* @throws Exception If something goes wrong.
514514
*/
515515
@Test
516-
public void getContainerWithIdStartsWithNotFound() throws Exception {
517-
new ListedContainers(
518-
new AssertRequest(
519-
new Response(
520-
HttpStatus.SC_NO_CONTENT,
521-
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
522-
)
523-
),
524-
URI.create("http://localhost/test"),
525-
Mockito.mock(Docker.class)
526-
).get("df2419f4").start();
527-
}
528-
529-
/**
530-
* RtContainers.get() returns an RtContainer with the container id.
531-
* @throws Exception If something goes wrong.
532-
*/
533-
@Test
534-
public void getContainerWithIdStopWithNotFound() throws Exception {
535-
new ListedContainers(
536-
new AssertRequest(
537-
new Response(
538-
HttpStatus.SC_NO_CONTENT,
539-
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
540-
)
541-
),
542-
URI.create("http://localhost/test"),
543-
Mockito.mock(Docker.class)
544-
).get("df2419f4").stop();
516+
public void getContainerWithId() throws Exception {
517+
MatcherAssert.assertThat(
518+
new ListedContainers(
519+
new AssertRequest(
520+
new Response(
521+
HttpStatus.SC_OK,
522+
"{ \"Id\": \"df2419f4\", \"Warnings\": [ ] }"
523+
)
524+
),
525+
URI.create("http://localhost/test"),
526+
Mockito.mock(Docker.class)
527+
).get("df2419f4").getString("Id"),
528+
Matchers.is("df2419f4")
529+
);
545530
}
546531
}

0 commit comments

Comments
 (0)