forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventsTest.java
More file actions
64 lines (53 loc) · 2.4 KB
/
Copy pathEventsTest.java
File metadata and controls
64 lines (53 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.github.dockerjava.api.model;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.core.RemoteApiVersion;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import static com.github.dockerjava.api.model.EventType.CONTAINER;
import static com.github.dockerjava.test.serdes.JSONSamples.testRoundTrip;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
/**
* @author Kanstantsin Shautsou
*/
public class EventsTest {
@Test
public void serderDocs1() throws IOException {
final ObjectMapper mapper = new ObjectMapper();
final JavaType type = mapper.getTypeFactory().uncheckedSimpleType(Event.class);
final Event event = testRoundTrip(RemoteApiVersion.VERSION_1_24,
"/events/docs1.json",
type
);
assertThat(event, notNullValue());
assertThat(event.getType(), is(CONTAINER));
assertThat(event.getAction(), is("create"));
assertThat(event.getId(), is("ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743"));
assertThat(event.getFrom(), is("alpine"));
assertThat(event.getTime(), is(1461943101L));
assertThat(event.getNode(), nullValue());
assertThat(event.getTimeNano(), is(1461943101381709551L));
final HashMap<String, String> attributes = new HashMap<>();
attributes.put("com.example.some-label", "some-label-value");
attributes.put("image", "alpine");
attributes.put("name", "my-container");
final EventActor actor = new EventActor()
.withId("ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743")
.withAttributes(attributes);
final Event event1 = new Event()
.withType(CONTAINER)
.withStatus("create")
.withId("ede54ee1afda366ab42f824e8a5ffd195155d853ceaec74a927f249ea270c743")
.withFrom("alpine")
.withTime(1461943101L)
.withTimenano(1461943101381709551L)
.withAction("create")
.withEventActor(actor);
assertThat(event1, equalTo(event));
}
}