|
26 | 26 | import java.io.IOException; |
27 | 27 | import java.util.ArrayList; |
28 | 28 | import java.util.List; |
29 | | -import java.util.function.BiFunction; |
30 | | -import java.util.function.Function; |
31 | 29 |
|
32 | 30 | import static cloud.dnation.hetznerclient.TestHelper.resourceAsString; |
33 | 31 | import static org.junit.Assert.assertEquals; |
34 | 32 | import static org.junit.Assert.assertNull; |
35 | 33 |
|
| 34 | +@SuppressWarnings("DataFlowIssue") |
36 | 35 | public class BasicTest { |
37 | 36 | private static MockWebServer ws; |
38 | 37 | private static HetznerApi api; |
@@ -129,6 +128,26 @@ public void testGetFirewallById() throws IOException { |
129 | 128 | assertEquals("22", result.getFirewall().getRules().get(0).getPort()); |
130 | 129 | } |
131 | 130 |
|
| 131 | + @Test |
| 132 | + public void testGetServerActions() throws IOException{ |
| 133 | + ws.enqueue(new MockResponse().setBody(resourceAsString("get-lb-actions.json"))); |
| 134 | + Call<GetActionsResponse> call; |
| 135 | + GetActionsResponse result; |
| 136 | + call = api.getResourceActions("load_balancers", null, 0, 25); |
| 137 | + result = call.execute().body(); |
| 138 | + assertEquals(4, result.getActions().size()); |
| 139 | + assertEquals(100, (int) result.getActions().get(0).getProgress()); |
| 140 | + assertEquals("remove_target", result.getActions().get(0).getCommand()); |
| 141 | + |
| 142 | + List<Long> ids = new ArrayList<>(); |
| 143 | + ids.add(99999L); |
| 144 | + ws.enqueue(new MockResponse().setBody(resourceAsString("get-lb-actions-with-id.json"))); |
| 145 | + call = api.getResourceActions("load_balancers", ids, 0, 25); |
| 146 | + result = call.execute().body(); |
| 147 | + assertEquals(1, result.getActions().size()); |
| 148 | + assertEquals(100, (int) result.getActions().get(0).getProgress()); |
| 149 | + assertEquals("remove_target", result.getActions().get(0).getCommand()); |
| 150 | + } |
132 | 151 |
|
133 | 152 | @Test |
134 | 153 | public void testGetFirewallByIdInvalid() throws IOException { |
|
0 commit comments