|
| 1 | +/** |
| 2 | + * Copyright (c) 2018, Mihai Emil Andronache |
| 3 | + * All rights reserved. |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions are met: |
| 6 | + * 1)Redistributions of source code must retain the above copyright notice, |
| 7 | + * this list of conditions and the following disclaimer. |
| 8 | + * 2)Redistributions in binary form must reproduce the above copyright notice, |
| 9 | + * this list of conditions and the following disclaimer in the documentation |
| 10 | + * and/or other materials provided with the distribution. |
| 11 | + * 3)Neither the name of docker-java-api nor the names of its |
| 12 | + * contributors may be used to endorse or promote products derived from |
| 13 | + * this software without specific prior written permission. |
| 14 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 15 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 18 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 19 | + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 20 | + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 21 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 22 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 23 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 24 | + * POSSIBILITY OF SUCH DAMAGE. |
| 25 | + */ |
| 26 | +package com.amihaiemil.docker; |
| 27 | + |
| 28 | +import com.amihaiemil.docker.mock.AssertRequest; |
| 29 | +import com.amihaiemil.docker.mock.Response; |
| 30 | +import java.net.URI; |
| 31 | +import org.hamcrest.MatcherAssert; |
| 32 | +import org.hamcrest.collection.IsIterableWithSize; |
| 33 | +import org.hamcrest.core.IsEqual; |
| 34 | +import org.junit.Test; |
| 35 | + |
| 36 | +/** |
| 37 | + * Tests for {@link RtNetworks}. |
| 38 | + * |
| 39 | + * @author George Aristy ([email protected]) |
| 40 | + * @version $Id$ |
| 41 | + * @since 0.0.4 |
| 42 | + */ |
| 43 | +public final class RtNetworksTest { |
| 44 | + /** |
| 45 | + * RtNetworks must iterate all networks returned by docker's API. |
| 46 | + */ |
| 47 | + @Test |
| 48 | + public void iterateNetworks() { |
| 49 | + MatcherAssert.assertThat( |
| 50 | + "Cannot iterate networks in JSON", |
| 51 | + new RtNetworks( |
| 52 | + new AssertRequest( |
| 53 | + new Response( |
| 54 | + 200, |
| 55 | + // @checkstyle LineLength (20 lines) |
| 56 | + "[\n" |
| 57 | + + " {\n" |
| 58 | + + " \"Name\": \"bridge\",\n" |
| 59 | + + " \"Id\": \"f2de39df4171b0dc801e8002d1d999b77256983dfc63041c0f34030aa3977566\",\n" |
| 60 | + + " \"Created\": \"2016-10-19T06:21:00.416543526Z\"\n" |
| 61 | + + " },\n" |
| 62 | + + " {\n" |
| 63 | + + " \"Name\": \"none\",\n" |
| 64 | + + " \"Id\": \"e086a3893b05ab69242d3c44e49483a3bbbd3a26b46baa8f61ab797c1088d794\",\n" |
| 65 | + + " \"Created\": \"0001-01-01T00:00:00Z\"\n" |
| 66 | + + " },\n" |
| 67 | + + " {\n" |
| 68 | + + " \"Name\": \"host\",\n" |
| 69 | + + " \"Id\": \"13e871235c677f196c4e1ecebb9dc733b9b2d2ab589e30c539efeda84a24215e\",\n" |
| 70 | + + " \"Created\": \"0001-01-01T00:00:00Z\"\n" |
| 71 | + + " }\n" |
| 72 | + + "]" |
| 73 | + ) |
| 74 | + ), |
| 75 | + URI.create("http://test.docker.com") |
| 76 | + ), |
| 77 | + new IsIterableWithSize<>(new IsEqual<>(3)) |
| 78 | + ); |
| 79 | + } |
| 80 | +} |
0 commit comments