Skip to content

Commit c6db075

Browse files
committed
fix formatting
1 parent 6515717 commit c6db075

File tree

4 files changed

+178
-173
lines changed

4 files changed

+178
-173
lines changed

core-test/src/main/java/org/openstack4j/api/AbstractTest.java

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
package org.openstack4j.api;
22

3-
import com.fasterxml.jackson.annotation.JsonInclude.*;
4-
import com.fasterxml.jackson.databind.*;
5-
import com.google.common.io.*;
6-
import okhttp3.mockwebserver.*;
7-
import org.bouncycastle.util.io.*;
8-
import org.openstack4j.api.OSClient.*;
9-
import org.openstack4j.core.transport.internal.*;
10-
import org.openstack4j.openstack.*;
11-
import org.openstack4j.openstack.identity.v2.domain.*;
3+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
4+
import com.fasterxml.jackson.databind.DeserializationFeature;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.fasterxml.jackson.databind.SerializationFeature;
7+
import com.google.common.io.ByteStreams;
8+
import okhttp3.mockwebserver.MockResponse;
9+
import okhttp3.mockwebserver.MockWebServer;
10+
import okhttp3.mockwebserver.RecordedRequest;
11+
import org.bouncycastle.util.io.Streams;
12+
import org.openstack4j.api.OSClient.OSClientV2;
13+
import org.openstack4j.api.OSClient.OSClientV3;
14+
import org.openstack4j.core.transport.internal.HttpExecutor;
15+
import org.openstack4j.openstack.OSFactory;
16+
import org.openstack4j.openstack.identity.v2.domain.KeystoneAccess;
1217
import org.openstack4j.openstack.identity.v3.domain.KeystoneToken;
13-
import org.slf4j.*;
14-
import org.testng.annotations.*;
15-
16-
import java.io.*;
17-
import java.net.*;
18-
import java.util.*;
18+
import org.slf4j.Logger;
19+
import org.slf4j.LoggerFactory;
20+
import org.testng.annotations.AfterClass;
21+
import org.testng.annotations.BeforeClass;
22+
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.net.InetAddress;
26+
import java.net.UnknownHostException;
27+
import java.util.HashMap;
28+
import java.util.Map;
1929

2030
/**
2131
* Base Test class which handles Mocking a Webserver to fullfill and test
@@ -26,19 +36,19 @@
2636
public abstract class AbstractTest {
2737

2838
protected enum Service {
29-
IDENTITY(5000),
39+
IDENTITY(5000),
3040
NETWORK(9696),
31-
COMPUTE(8774),
32-
BLOCK_STORAGE(8776),
33-
METERING(8087),
34-
TELEMETRY(8087),
35-
SHARE(8786),
41+
COMPUTE(8774),
42+
BLOCK_STORAGE(8776),
43+
METERING(8087),
44+
TELEMETRY(8087),
45+
SHARE(8786),
3646
OBJECT_STORAGE(8800),
3747
BARBICAN(9311),
3848
MAGNUM(9511),
3949
ORCHESTRATION(8004),
4050
DATABASE(8779),
41-
TACKER(9890),
51+
TACKER(9890),
4252
IMAGE(9292),
4353
ARTIFACT(9494),
4454
CLUSTERING(8778),
@@ -52,7 +62,7 @@ private Service(int port) {
5262
}
5363

5464
}
55-
65+
5666
private final Logger LOG = LoggerFactory.getLogger(getClass().getName());
5767

5868
protected static final String JSON_ACCESS = "/identity/v2/access.json";
@@ -100,7 +110,7 @@ protected void respondWith(String resource) throws IOException {
100110

101111
/**
102112
* Responds with specified status code and no body
103-
*
113+
*
104114
* @param statusCode the status code to respond with
105115
*/
106116
protected void respondWith(int statusCode) {
@@ -109,8 +119,8 @@ protected void respondWith(int statusCode) {
109119

110120
/**
111121
* Responds with specified status code, no body and optional headers
112-
*
113-
* @param headers optional headers
122+
*
123+
* @param headers optional headers
114124
* @param statusCode the status code to respond with
115125
*/
116126
protected void respondWith(Map<String, String> headers, int statusCode) {
@@ -119,9 +129,9 @@ protected void respondWith(Map<String, String> headers, int statusCode) {
119129

120130
/**
121131
* Responds with specified status code and json body
122-
*
132+
*
123133
* @param statusCode the status code to respond with
124-
* @param jsonBody the json body
134+
* @param jsonBody the json body
125135
*/
126136
protected void respondWith(int statusCode, String jsonBody) {
127137
Map<String, String> headers = new HashMap<String, String>();
@@ -131,10 +141,10 @@ protected void respondWith(int statusCode, String jsonBody) {
131141

132142
/**
133143
* Responds with specified status code, body and optional headers
134-
*
135-
* @param headers optional headers
144+
*
145+
* @param headers optional headers
136146
* @param statusCode the status code to respond with
137-
* @param body the response body
147+
* @param body the response body
138148
*/
139149
protected void respondWith(Map<String, String> headers, int statusCode, String body) {
140150
MockResponse r = new MockResponse();
@@ -151,9 +161,9 @@ protected void respondWith(Map<String, String> headers, int statusCode, String b
151161
/**
152162
* Responds with given header, status code, body from json resource file.
153163
*
154-
* @param headers the specified header
164+
* @param headers the specified header
155165
* @param statusCode the status code to respond with
156-
* @param resource the json resource file
166+
* @param resource the json resource file
157167
* @throws IOException Signals that an I/O exception has occurred
158168
*/
159169
protected void respondWithHeaderAndResource(Map<String, String> headers, int statusCode, String resource)
@@ -174,16 +184,16 @@ protected void respondWithCodeAndResource(int statusCode, String resource) throw
174184
* Callers should use this to verify the request was sent as intended.
175185
* This method will block until the request is available, possibly forever.
176186
* <br/>
177-
* <b>Be aware that this method will catch all the previous requests made
187+
* <b>Be aware that this method will catch all the previous requests made
178188
* to the mock server, also from other previous tests!
179189
* Make sure to take all the requests made by methods in the same test class.</b>
180-
*
190+
*
181191
* @return the head of the request queue
182192
*/
183193
protected RecordedRequest takeRequest() throws InterruptedException {
184194
return server.takeRequest();
185195
}
186-
196+
187197
protected String authURL(String path) {
188198
return String.format("http://%s:5000%s", getHost(), path);
189199
}
@@ -201,7 +211,7 @@ protected void afterTest() {
201211
protected void associateClientV2(OSClientV2 osv2) {
202212
this.osv2 = osv2;
203213
}
204-
214+
205215
protected void associateClientV3(OSClientV3 osv3) {
206216
this.osv3 = osv3;
207217
}
Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,64 @@
11
package org.openstack4j.api.dns.v2;
22

33
import com.google.common.collect.ImmutableList;
4-
import com.google.common.collect.ImmutableMap;
54
import org.openstack4j.api.AbstractTest;
6-
import org.openstack4j.api.Builders;
7-
import org.openstack4j.model.common.ActionResponse;
8-
import org.openstack4j.model.dns.v2.*;
5+
import org.openstack4j.model.dns.v2.Action;
6+
import org.openstack4j.model.dns.v2.Recordset;
7+
import org.openstack4j.model.dns.v2.Status;
98
import org.testng.annotations.Test;
109

1110
import java.util.List;
12-
import java.util.Map;
1311

1412
import static org.testng.Assert.assertEquals;
1513
import static org.testng.Assert.assertFalse;
16-
import static org.testng.Assert.assertTrue;
1714

1815
/**
1916
* Tests the DNS/Designate API version 2 ZoneService
2017
*/
2118
@Test(groups = "dnsV2", suiteName = "DNS/Designate_V2")
2219
public class DesignateRecordsetServiceTest extends AbstractTest {
2320

24-
private static final String JSON_RECORDSET = "/dns/v2/create_recordset.json";
25-
private static final String JSON_RECORDSETLIST = "/dns/v2/list_recordsets.json";
21+
private static final String JSON_RECORDSET = "/dns/v2/create_recordset.json";
22+
private static final String JSON_RECORDSETLIST = "/dns/v2/list_recordsets.json";
2623

27-
private static final String ZONE_ID = "2150b1bf-dee2-4221-9d85-11f7886fb15f";
28-
private static final String RECORDSET_NAME = "example.org.";
29-
private static final String RECORDSET_TYPE = "A";
30-
private static final ImmutableList<String> RECORDSET_RECORDS = ImmutableList.of("10.1.0.2");
31-
private static final Status RECORDSET_STATUS = Status.PENDING;
32-
private static final Action RECORDSET_ACTION = Action.CREATE;
33-
private static final Integer RECORDSET_VERSION = 1;
24+
private static final String ZONE_ID = "2150b1bf-dee2-4221-9d85-11f7886fb15f";
25+
private static final String RECORDSET_NAME = "example.org.";
26+
private static final String RECORDSET_TYPE = "A";
27+
private static final ImmutableList<String> RECORDSET_RECORDS = ImmutableList.of("10.1.0.2");
28+
private static final Status RECORDSET_STATUS = Status.PENDING;
29+
private static final Action RECORDSET_ACTION = Action.CREATE;
30+
private static final Integer RECORDSET_VERSION = 1;
3431

35-
@Override
36-
protected Service service() {
37-
return Service.DNS;
38-
}
32+
@Override
33+
protected Service service() {
34+
return Service.DNS;
35+
}
3936

40-
public void recordsetCreateTest() throws Exception {
37+
public void recordsetCreateTest() throws Exception {
4138

42-
respondWith(JSON_RECORDSET);
39+
respondWith(JSON_RECORDSET);
4340

44-
Recordset recordset = osv3().dns().recordsets().create(ZONE_ID, RECORDSET_NAME, RECORDSET_TYPE, RECORDSET_RECORDS);
41+
Recordset recordset = osv3().dns().recordsets().create(ZONE_ID, RECORDSET_NAME, RECORDSET_TYPE, RECORDSET_RECORDS);
4542

46-
assertEquals(recordset.getZoneId(), ZONE_ID);
47-
assertEquals(recordset.getName(), RECORDSET_NAME);
48-
assertEquals(recordset.getType(), RECORDSET_TYPE);
49-
assertEquals(recordset.getRecords(), RECORDSET_RECORDS);
50-
assertEquals(recordset.getStatus(), RECORDSET_STATUS);
51-
assertEquals(recordset.getAction(), RECORDSET_ACTION);
43+
assertEquals(recordset.getZoneId(), ZONE_ID);
44+
assertEquals(recordset.getName(), RECORDSET_NAME);
45+
assertEquals(recordset.getType(), RECORDSET_TYPE);
46+
assertEquals(recordset.getRecords(), RECORDSET_RECORDS);
47+
assertEquals(recordset.getStatus(), RECORDSET_STATUS);
48+
assertEquals(recordset.getAction(), RECORDSET_ACTION);
5249

53-
}
50+
}
5451

55-
public void recordsetListTest() throws Exception {
52+
public void recordsetListTest() throws Exception {
5653

57-
respondWith(JSON_RECORDSETLIST);
54+
respondWith(JSON_RECORDSETLIST);
5855

59-
List<? extends Recordset> recordsetList = osv3().dns().recordsets().list(ZONE_ID);
56+
List<? extends Recordset> recordsetList = osv3().dns().recordsets().list(ZONE_ID);
6057

61-
assertFalse(recordsetList.isEmpty());
62-
assertEquals(recordsetList.get(0).getZoneId(), ZONE_ID);
63-
assertEquals(recordsetList.get(0).getVersion(), RECORDSET_VERSION);
58+
assertFalse(recordsetList.isEmpty());
59+
assertEquals(recordsetList.get(0).getZoneId(), ZONE_ID);
60+
assertEquals(recordsetList.get(0).getVersion(), RECORDSET_VERSION);
6461

65-
}
62+
}
6663

6764
}

core-test/src/main/java/org/openstack4j/api/dns/v2/DesignateZoneServiceTest.java

Lines changed: 43 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,77 +11,75 @@
1111

1212
import java.util.List;
1313

14-
import static org.testng.Assert.assertEquals;
15-
import static org.testng.Assert.assertFalse;
16-
import static org.testng.Assert.assertTrue;
14+
import static org.testng.Assert.*;
1715

1816
/**
1917
* Tests the DNS/Designate API version 2 ZoneService
2018
*/
2119
@Test(groups = "dnsV2", suiteName = "DNS/Designate_V2")
2220
public class DesignateZoneServiceTest extends AbstractTest {
2321

24-
private static final String JSON_ZONE = "/dns/v2/create_zone.json";
25-
private static final String JSON_ZONELIST = "/dns/v2/list_zones.json";
22+
private static final String JSON_ZONE = "/dns/v2/create_zone.json";
23+
private static final String JSON_ZONELIST = "/dns/v2/list_zones.json";
2624

27-
private static final String ZONE_NAME = "example.org.";
28-
private static final String ZONE_EMAIL = "[email protected]";
29-
private static final Status ZONE_STATUS = Status.ACTIVE;
30-
private static final Action ZONE_ACTION = Action.CREATE;
31-
private static final ZoneType ZONE_TYPE = ZoneType.PRIMARY;
32-
private static final Integer ZONE_TTL = 7200;
33-
private static final String ZONE_ID = "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3";
34-
private static final String ZONE_DESCRIPTION = "This is an example zone.";
35-
private static final String ZONE_PROJECT_ID = "4335d1f0-f793-11e2-b778-0800200c9a66";
25+
private static final String ZONE_NAME = "example.org.";
26+
private static final String ZONE_EMAIL = "[email protected]";
27+
private static final Status ZONE_STATUS = Status.ACTIVE;
28+
private static final Action ZONE_ACTION = Action.CREATE;
29+
private static final ZoneType ZONE_TYPE = ZoneType.PRIMARY;
30+
private static final Integer ZONE_TTL = 7200;
31+
private static final String ZONE_ID = "a86dba58-0043-4cc6-a1bb-69d5e86f3ca3";
32+
private static final String ZONE_DESCRIPTION = "This is an example zone.";
33+
private static final String ZONE_PROJECT_ID = "4335d1f0-f793-11e2-b778-0800200c9a66";
3634

37-
@Override
38-
protected Service service() {
39-
return Service.DNS;
40-
}
35+
@Override
36+
protected Service service() {
37+
return Service.DNS;
38+
}
4139

42-
public void zoneCreateTest() throws Exception {
40+
public void zoneCreateTest() throws Exception {
4341

44-
respondWith(JSON_ZONE);
42+
respondWith(JSON_ZONE);
4543

46-
Zone zone = osv3().dns().zones().create(ZONE_NAME, ZONE_EMAIL);
44+
Zone zone = osv3().dns().zones().create(ZONE_NAME, ZONE_EMAIL);
4745

48-
assertEquals(zone.getName(), ZONE_NAME);
49-
assertEquals(zone.getEmail(), ZONE_EMAIL);
50-
assertEquals(zone.getStatus(), ZONE_STATUS);
51-
assertEquals(zone.getAction(), ZONE_ACTION);
52-
assertEquals(zone.getType(), ZONE_TYPE);
53-
assertEquals(zone.getTTL(), ZONE_TTL);
46+
assertEquals(zone.getName(), ZONE_NAME);
47+
assertEquals(zone.getEmail(), ZONE_EMAIL);
48+
assertEquals(zone.getStatus(), ZONE_STATUS);
49+
assertEquals(zone.getAction(), ZONE_ACTION);
50+
assertEquals(zone.getType(), ZONE_TYPE);
51+
assertEquals(zone.getTTL(), ZONE_TTL);
5452

55-
}
53+
}
5654

57-
public void zoneUpdateTest() throws Exception {
55+
public void zoneUpdateTest() throws Exception {
5856

59-
respondWith(JSON_ZONE);
57+
respondWith(JSON_ZONE);
6058

61-
Zone zone = osv3().dns().zones().update(Builders.dnsV2().zone().id(ZONE_ID).description(ZONE_DESCRIPTION).build());
59+
Zone zone = osv3().dns().zones().update(Builders.dnsV2().zone().id(ZONE_ID).description(ZONE_DESCRIPTION).build());
6260

63-
assertEquals(zone.getId(), ZONE_ID);
64-
assertEquals(zone.getDescription(), ZONE_DESCRIPTION);
61+
assertEquals(zone.getId(), ZONE_ID);
62+
assertEquals(zone.getDescription(), ZONE_DESCRIPTION);
6563

66-
}
64+
}
6765

68-
public void zoneListTest() throws Exception {
66+
public void zoneListTest() throws Exception {
6967

70-
respondWith(JSON_ZONELIST);
68+
respondWith(JSON_ZONELIST);
7169

72-
List<? extends Zone> zoneList = osv3().dns().zones().list();
70+
List<? extends Zone> zoneList = osv3().dns().zones().list();
7371

74-
assertFalse(zoneList.isEmpty());
75-
assertEquals(zoneList.get(0).getProjectId(),ZONE_PROJECT_ID);
76-
}
72+
assertFalse(zoneList.isEmpty());
73+
assertEquals(zoneList.get(0).getProjectId(), ZONE_PROJECT_ID);
74+
}
7775

78-
public void zoneDeleteTest() throws Exception {
76+
public void zoneDeleteTest() throws Exception {
7977

80-
respondWith(204);
78+
respondWith(204);
8179

82-
ActionResponse zoneDeleteResponse = osv3().dns().zones().delete(ZONE_ID);
80+
ActionResponse zoneDeleteResponse = osv3().dns().zones().delete(ZONE_ID);
8381

84-
assertTrue(zoneDeleteResponse.isSuccess());
85-
}
82+
assertTrue(zoneDeleteResponse.isSuccess());
83+
}
8684

8785
}

0 commit comments

Comments
 (0)