forked from docker-java/docker-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchImagesCmdIT.java
More file actions
64 lines (48 loc) · 2.47 KB
/
Copy pathSearchImagesCmdIT.java
File metadata and controls
64 lines (48 loc) · 2.47 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.cmd;
import com.github.dockerjava.api.exception.DockerException;
import com.github.dockerjava.api.model.SearchItem;
import org.hamcrest.Matcher;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import static ch.lambdaj.Lambda.filter;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testinfected.hamcrest.jpa.HasFieldWithValue.hasField;
public class SearchImagesCmdIT extends CmdIT {
public static final Logger LOG = LoggerFactory.getLogger(SearchImagesCmdIT.class);
@Test
public void searchImages() throws DockerException {
List<SearchItem> dockerSearch = dockerRule.getClient().searchImagesCmd("busybox").exec();
LOG.info("Search returned {}", dockerSearch.toString());
Matcher matcher = hasItem(hasField("name", equalTo("busybox")));
assertThat(dockerSearch, matcher);
assertThat(filter(hasField("name", is("busybox")), dockerSearch).size(), equalTo(1));
}
@Test(expected = IllegalArgumentException.class)
public void searchImagesWithInvalidMinimumLimit() throws DockerException {
dockerRule.getClient().searchImagesCmd("busybox").withLimit(0).exec();
}
@Test(expected = IllegalArgumentException.class)
public void searchImagesWithInvalidMaximumLimit() throws DockerException {
dockerRule.getClient().searchImagesCmd("busybox").withLimit(101).exec();
}
@Test
public void searchImagesWithValidMinimumLimit() throws DockerException {
List<SearchItem> dockerSearch = dockerRule.getClient().searchImagesCmd("busybox").withLimit(1).exec();
LOG.info("Search returned {}", dockerSearch.toString());
Matcher matcher = hasItem(hasField("name", equalTo("busybox")));
assertThat(dockerSearch, matcher);
assertThat(filter(hasField("name", is("busybox")), dockerSearch).size(), equalTo(1));
assertThat(dockerSearch.size(), equalTo(1));
}
@Test
public void searchImagesWithValidMaximumLimit() throws DockerException {
List<SearchItem> dockerSearch = dockerRule.getClient().searchImagesCmd("busybox").withLimit(1).exec();
LOG.info("Search returned {}", dockerSearch.toString());
Matcher matcher = hasItem(hasField("name", equalTo("busybox")));
assertThat(dockerSearch, matcher);
assertThat(filter(hasField("name", is("busybox")), dockerSearch).size(), equalTo(1));
}
}