11package com .github .dockerjava .api .command ;
22
3+ import com .fasterxml .jackson .databind .JavaType ;
4+ import com .fasterxml .jackson .databind .ObjectMapper ;
5+ import com .github .dockerjava .api .model .ContainerConfig ;
6+ import org .testng .annotations .Test ;
7+
8+ import java .io .IOException ;
9+ import java .util .Collections ;
10+
311import static com .github .dockerjava .core .RemoteApiVersion .VERSION_1_22 ;
412import static com .github .dockerjava .test .serdes .JSONSamples .testRoundTrip ;
513import static org .hamcrest .MatcherAssert .assertThat ;
1321import static org .hamcrest .Matchers .notNullValue ;
1422import static org .hamcrest .Matchers .nullValue ;
1523
16- import java .io .IOException ;
17- import java .util .Collections ;
18-
19- import org .testng .annotations .Test ;
20-
21- import com .fasterxml .jackson .databind .JavaType ;
22- import com .fasterxml .jackson .databind .ObjectMapper ;
23- import com .github .dockerjava .api .model .ContainerConfig ;
24-
2524/**
2625 * @author Kanstantsin Shautsou
2726 */
2827public class InspectImageResponseTest {
29-
3028 @ Test
3129 public void serder1_22Json () throws IOException {
3230 final ObjectMapper mapper = new ObjectMapper ();
3331 final JavaType type = mapper .getTypeFactory ().constructType (InspectImageResponse .class );
3432
35- final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 , "images/image1/inspect1.json" , type );
33+ final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 ,
34+ "images/image1/inspect1.json" ,
35+ type
36+ );
3637
37- final ContainerConfig config = new ContainerConfig ().withAttachStdout (false )
38+ final ContainerConfig config = new ContainerConfig ()
39+ .withAttachStderr (false )
40+ .withAttachStdin (false )
41+ .withAttachStdout (false )
3842 .withCmd (null )
3943 .withDomainName ("" )
4044 .withEntrypoint (null )
41- .withEnv (new String [] {"HOME=/" ,
42- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
45+ .withEnv (new String []{"HOME=/" , "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
4346 .withExposedPorts (null )
4447 .withHostName ("aee9ba801acc" )
4548 .withImage ("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158" )
4649 .withLabels (null )
4750 .withMacAddress (null )
4851 .withNetworkDisabled (null )
49- .withOnBuild (new String [] {})
52+ .withOnBuild (new String []{})
5053 .withStdinOpen (false )
5154 .withPortSpecs (null )
5255 .withStdInOnce (false )
@@ -55,21 +58,21 @@ public void serder1_22Json() throws IOException {
5558 .withVolumes (null )
5659 .withWorkingDir ("" );
5760
58- final ContainerConfig containerConfig = new ContainerConfig ().withAttachStderr (false )
61+ final ContainerConfig containerConfig = new ContainerConfig ()
62+ .withAttachStderr (false )
5963 .withAttachStdin (false )
6064 .withAttachStdout (false )
61- .withCmd (new String [] {"/bin/sh" , "-c" , "#(nop) MAINTAINER hack@worldticket.net" })
65+ .withCmd (new String []{"/bin/sh" , "-c" , "#(nop) MAINTAINER hack@worldticket.net" })
6266 .withDomainName ("" )
6367 .withEntrypoint (null )
64- .withEnv (new String [] {"HOME=/" ,
65- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
68+ .withEnv (new String []{"HOME=/" , "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" })
6669 .withExposedPorts (null )
6770 .withHostName ("aee9ba801acc" )
6871 .withImage ("511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158" )
6972 .withLabels (null )
7073 .withMacAddress (null )
7174 .withNetworkDisabled (null )
72- .withOnBuild (new String [] {})
75+ .withOnBuild (new String []{})
7376 .withStdinOpen (false )
7477 .withPortSpecs (null )
7578 .withStdInOnce (false )
@@ -110,6 +113,7 @@ public void serder1_22Json() throws IOException {
110113
111114 assertThat (inspectImage .getVirtualSize (), is (0L ));
112115
116+
113117 final InspectImageResponse inspectImageResponse = new InspectImageResponse ().withArch ("amd64" )
114118 .withAuthor ("hack@worldticket.net" )
115119 .withComment ("" )
@@ -123,42 +127,55 @@ public void serder1_22Json() throws IOException {
123127 .withParent ("" )
124128 .withSize (0L )
125129 .withRepoTags (Collections .singletonList ("hackmann/empty:latest" ))
126- .withRepoDigests (Collections .<String > emptyList ())
130+ .withRepoDigests (Collections .<String >emptyList ())
127131 .withVirtualSize (0L )
128132 .withGraphDriver (aufsGraphDriver );
129133
130134 assertThat (inspectImage , equalTo (inspectImageResponse ));
131135 }
132136
137+
133138 @ Test
134139 public void serder1_22_doc () throws IOException {
135140 final ObjectMapper mapper = new ObjectMapper ();
136141 final JavaType type = mapper .getTypeFactory ().constructType (InspectImageResponse .class );
137142
138- final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 , "images/docImage/doc.json" , type );
143+ final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 ,
144+ "images/docImage/doc.json" ,
145+ type
146+ );
139147
140148 assertThat (inspectImage , notNullValue ());
141149
142150 assertThat (inspectImage .getRepoDigests (), hasSize (1 ));
143151 assertThat (inspectImage .getRepoDigests (),
144-
145- contains ( "localhost:5000/test/busybox/example@"
146- + "sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" ) );
152+ contains ( "localhost:5000/test/busybox/example@" +
153+ "sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf" )
154+ );
147155
148156 assertThat (inspectImage .getRepoTags (), hasSize (3 ));
149- assertThat (inspectImage .getRepoTags (), containsInAnyOrder ("example:1.0" , "example:latest" , "example:stable" ));
157+ assertThat (inspectImage .getRepoTags (), containsInAnyOrder (
158+ "example:1.0" ,
159+ "example:latest" ,
160+ "example:stable"
161+ ));
150162 }
151163
152164 @ Test
153165 public void serder1_22_inspect_doc () throws IOException {
154166 final ObjectMapper mapper = new ObjectMapper ();
155167 final JavaType type = mapper .getTypeFactory ().constructType (InspectImageResponse .class );
156168
157- final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 , "images/docImage/inspect_doc.json" , type );
169+ final InspectImageResponse inspectImage = testRoundTrip (VERSION_1_22 ,
170+ "images/docImage/inspect_doc.json" ,
171+ type
172+ );
158173
159- GraphData newGraphData = new GraphData ().withDeviceId ("5" )
174+ GraphData newGraphData = new GraphData ()
175+ .withDeviceId ("5" )
160176 .withDeviceName ("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47" )
161177 .withDeviceSize ("171798691840" );
178+
162179 assertThat (inspectImage , notNullValue ());
163180 GraphDriver graphDriver = inspectImage .getGraphDriver ();
164181 assertThat (graphDriver , notNullValue ());
@@ -167,8 +184,10 @@ public void serder1_22_inspect_doc() throws IOException {
167184 assertThat (data , is (newGraphData ));
168185
169186 assertThat (data .getDeviceId (), is ("5" ));
170- assertThat (data .getDeviceName (), is ("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47" ));
171- assertThat (data .getDeviceSize (), is ("171798691840" ));
187+ assertThat (data .getDeviceName (),
188+ is ("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47" ));
189+ assertThat (data .getDeviceSize (),
190+ is ("171798691840" ));
172191 }
173192
174193 @ Test
@@ -186,6 +205,5 @@ private void testOverlayNetworkRootDir() throws IOException {
186205 assertThat (graphDriver , equalTo (overlayGraphDriver ));
187206 assertThat (graphDriver .getName (), is ("overlay" ));
188207 assertThat (graphDriver .getData (), equalTo (overlayGraphData ));
189-
190208 }
191209}
0 commit comments