Skip to content

Commit 13ef31e

Browse files
committed
GraphData is more complex structure.
Fixes #538
1 parent 284b26b commit 13ef31e

File tree

4 files changed

+268
-3
lines changed

4 files changed

+268
-3
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
package com.github.dockerjava.api.command;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import org.apache.commons.lang.builder.EqualsBuilder;
5+
import org.apache.commons.lang.builder.HashCodeBuilder;
6+
import org.apache.commons.lang.builder.ToStringBuilder;
7+
8+
import javax.annotation.CheckForNull;
9+
10+
/**
11+
* part of {@link GraphDriver}
12+
* @author Kanstantsin Shautsou
13+
*/
14+
public class GraphData {
15+
@JsonProperty("DeviceId")
16+
private String deviceId;
17+
18+
@JsonProperty("DeviceName")
19+
private String deviceName;
20+
21+
@JsonProperty("DeviceSize")
22+
private String deviceSize;
23+
24+
/**
25+
* @see #deviceId
26+
*/
27+
@CheckForNull
28+
public String getDeviceId() {
29+
return deviceId;
30+
}
31+
32+
/**
33+
* @see #deviceId
34+
*/
35+
public GraphData withDeviceId(String deviceId) {
36+
this.deviceId = deviceId;
37+
return this;
38+
}
39+
40+
/**
41+
* @see #deviceName
42+
*/
43+
@CheckForNull
44+
public String getDeviceName() {
45+
return deviceName;
46+
}
47+
48+
/**
49+
* @see #deviceName
50+
*/
51+
public GraphData withDeviceName(String deviceName) {
52+
this.deviceName = deviceName;
53+
return this;
54+
}
55+
56+
/**
57+
* @see #deviceSize
58+
*/
59+
@CheckForNull
60+
public String getDeviceSize() {
61+
return deviceSize;
62+
}
63+
64+
/**
65+
* @see #deviceSize
66+
*/
67+
public GraphData withDeviceSize(String deviceSize) {
68+
this.deviceSize = deviceSize;
69+
return this;
70+
}
71+
72+
@Override
73+
public String toString() {
74+
return ToStringBuilder.reflectionToString(this);
75+
}
76+
77+
@Override
78+
public boolean equals(Object o) {
79+
return EqualsBuilder.reflectionEquals(this, o);
80+
}
81+
82+
@Override
83+
public int hashCode() {
84+
return HashCodeBuilder.reflectionHashCode(this);
85+
}
86+
}

src/main/java/com/github/dockerjava/api/command/GraphDriver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@ public class GraphDriver {
2424
* @since {@link com.github.dockerjava.core.RemoteApiVersion#VERSION_1_21}
2525
*/
2626
@JsonProperty("Data")
27-
private String data;
27+
private GraphData data;
2828

2929

3030
/**
3131
* @see #data
3232
*/
3333
@CheckForNull
34-
public String getData() {
34+
public GraphData getData() {
3535
return data;
3636
}
3737

3838
/**
3939
* @see #data
4040
*/
41-
public GraphDriver withData(String data) {
41+
public GraphDriver withData(GraphData data) {
4242
this.data = data;
4343
return this;
4444
}

src/test/java/com/github/dockerjava/api/command/InspectImageResponseTest.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,33 @@ public void serder1_22_doc() throws IOException {
160160
"example:stable"
161161
));
162162
}
163+
164+
@Test
165+
public void serder1_22_inspect_doc() throws IOException {
166+
final ObjectMapper mapper = new ObjectMapper();
167+
final JavaType type = mapper.getTypeFactory().constructType(InspectImageResponse.class);
168+
169+
final InspectImageResponse inspectImage = testRoundTrip(VERSION_1_22,
170+
"images/docImage/inspect_doc.json",
171+
type
172+
);
173+
174+
GraphData newGraphData = new GraphData()
175+
.withDeviceId("5")
176+
.withDeviceName("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47")
177+
.withDeviceSize("171798691840");
178+
179+
assertThat(inspectImage, notNullValue());
180+
GraphDriver graphDriver = inspectImage.getGraphDriver();
181+
assertThat(graphDriver, notNullValue());
182+
GraphData data = graphDriver.getData();
183+
184+
assertThat(data, is(newGraphData));
185+
186+
assertThat(data.getDeviceId(), is("5"));
187+
assertThat(data.getDeviceName(),
188+
is("docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47"));
189+
assertThat(data.getDeviceSize(),
190+
is("171798691840"));
191+
}
163192
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"Id": "d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
3+
"Created": "2015-06-08T16:18:02.505155285Z",
4+
"Path": "bash",
5+
"Args": [],
6+
"State": {
7+
"Running": false,
8+
"Paused": false,
9+
"Restarting": false,
10+
"OOMKilled": false,
11+
"Dead": false,
12+
"Pid": 0,
13+
"ExitCode": 0,
14+
"Error": "",
15+
"StartedAt": "2015-06-08T16:18:03.643865954Z",
16+
"FinishedAt": "2015-06-08T16:57:06.448552862Z"
17+
},
18+
"Image": "ded7cd95e059788f2586a51c275a4f151653779d6a7f4dad77c2bd34601d94e4",
19+
"NetworkSettings": {
20+
"Bridge": "",
21+
"SandboxID": "6b4851d1903e16dd6a567bd526553a86664361f31036eaaa2f8454d6f4611f6f",
22+
"HairpinMode": false,
23+
"LinkLocalIPv6Address": "",
24+
"LinkLocalIPv6PrefixLen": 0,
25+
"Ports": {},
26+
"SandboxKey": "/var/run/docker/netns/6b4851d1903e",
27+
"SecondaryIPAddresses": null,
28+
"SecondaryIPv6Addresses": null,
29+
"EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
30+
"Gateway": "172.17.0.1",
31+
"GlobalIPv6Address": "",
32+
"GlobalIPv6PrefixLen": 0,
33+
"IPAddress": "172.17.0.2",
34+
"IPPrefixLen": 16,
35+
"IPv6Gateway": "",
36+
"MacAddress": "02:42:ac:12:00:02",
37+
"Networks": {
38+
"bridge": {
39+
"NetworkID": "7ea29fc1412292a2d7bba362f9253545fecdfa8ce9a6e37dd10ba8bee7129812",
40+
"EndpointID": "7587b82f0dada3656fda26588aee72630c6fab1536d36e394b2bfbcf898c971d",
41+
"Gateway": "172.17.0.1",
42+
"IPAddress": "172.17.0.2",
43+
"IPPrefixLen": 16,
44+
"IPv6Gateway": "",
45+
"GlobalIPv6Address": "",
46+
"GlobalIPv6PrefixLen": 0,
47+
"MacAddress": "02:42:ac:12:00:02"
48+
}
49+
}
50+
},
51+
"ResolvConfPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/resolv.conf",
52+
"HostnamePath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hostname",
53+
"HostsPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/hosts",
54+
"LogPath": "/var/lib/docker/containers/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47/d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47-json.log",
55+
"Name": "/adoring_wozniak",
56+
"RestartCount": 0,
57+
"Driver": "devicemapper",
58+
"MountLabel": "",
59+
"ProcessLabel": "",
60+
"Mounts": [
61+
{
62+
"Source": "/data",
63+
"Destination": "/data",
64+
"Mode": "ro,Z",
65+
"RW": false,
66+
"Propagation": ""
67+
}
68+
],
69+
"AppArmorProfile": "",
70+
"ExecIDs": null,
71+
"HostConfig": {
72+
"Binds": null,
73+
"ContainerIDFile": "",
74+
"Memory": 0,
75+
"MemorySwap": 0,
76+
"CpuShares": 0,
77+
"CpuPeriod": 0,
78+
"CpusetCpus": "",
79+
"CpusetMems": "",
80+
"CpuQuota": 0,
81+
"BlkioWeight": 0,
82+
"OomKillDisable": false,
83+
"Privileged": false,
84+
"PortBindings": {},
85+
"Links": null,
86+
"PublishAllPorts": false,
87+
"Dns": null,
88+
"DnsSearch": null,
89+
"DnsOptions": null,
90+
"ExtraHosts": null,
91+
"VolumesFrom": null,
92+
"Devices": [],
93+
"NetworkMode": "bridge",
94+
"IpcMode": "",
95+
"PidMode": "",
96+
"UTSMode": "",
97+
"CapAdd": null,
98+
"CapDrop": null,
99+
"RestartPolicy": {
100+
"Name": "no",
101+
"MaximumRetryCount": 0
102+
},
103+
"SecurityOpt": null,
104+
"ReadonlyRootfs": false,
105+
"Ulimits": null,
106+
"LogConfig": {
107+
"Type": "json-file",
108+
"Config": {}
109+
},
110+
"CgroupParent": ""
111+
},
112+
"GraphDriver": {
113+
"Name": "devicemapper",
114+
"Data": {
115+
"DeviceId": "5",
116+
"DeviceName": "docker-253:1-2763198-d2cc496561d6d520cbc0236b4ba88c362c446a7619992123f11c809cded25b47",
117+
"DeviceSize": "171798691840"
118+
}
119+
},
120+
"Config": {
121+
"Hostname": "d2cc496561d6",
122+
"Domainname": "",
123+
"User": "",
124+
"AttachStdin": true,
125+
"AttachStdout": true,
126+
"AttachStderr": true,
127+
"ExposedPorts": null,
128+
"Tty": true,
129+
"OpenStdin": true,
130+
"StdinOnce": true,
131+
"Env": null,
132+
"Cmd": [
133+
"bash"
134+
],
135+
"Image": "fedora",
136+
"Volumes": null,
137+
"VolumeDriver": "",
138+
"WorkingDir": "",
139+
"Entrypoint": null,
140+
"NetworkDisabled": false,
141+
"MacAddress": "",
142+
"OnBuild": null,
143+
"Labels": {},
144+
"Memory": 0,
145+
"MemorySwap": 0,
146+
"CpuShares": 0,
147+
"Cpuset": "",
148+
"StopSignal": "SIGTERM"
149+
}
150+
}

0 commit comments

Comments
 (0)