Skip to content

Commit 1a7b935

Browse files
committed
Fixed compilation warnings
1 parent 03e92cb commit 1a7b935

11 files changed

+31
-31
lines changed

src/main/java/cd/go/contrib/elasticagent/KubernetesPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class KubernetesPlugin implements GoPlugin {
3535
public static final Logger LOG = Logger.getLoggerFor(KubernetesPlugin.class);
3636

3737
private PluginRequest pluginRequest;
38-
private AgentInstances agentInstances;
38+
private AgentInstances<KubernetesInstance> agentInstances;
3939

4040
@Override
4141
public void initializeGoApplicationAccessor(GoApplicationAccessor accessor) {

src/main/java/cd/go/contrib/elasticagent/executors/CreateAgentRequestExecutor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package cd.go.contrib.elasticagent.executors;
1818

1919
import cd.go.contrib.elasticagent.AgentInstances;
20+
import cd.go.contrib.elasticagent.KubernetesInstance;
2021
import cd.go.contrib.elasticagent.PluginRequest;
2122
import cd.go.contrib.elasticagent.RequestExecutor;
2223
import cd.go.contrib.elasticagent.requests.CreateAgentRequest;
@@ -26,11 +27,11 @@
2627
import static cd.go.contrib.elasticagent.KubernetesPlugin.LOG;
2728

2829
public class CreateAgentRequestExecutor implements RequestExecutor {
29-
private final AgentInstances agentInstances;
30+
private final AgentInstances<KubernetesInstance> agentInstances;
3031
private final PluginRequest pluginRequest;
3132
private final CreateAgentRequest request;
3233

33-
public CreateAgentRequestExecutor(CreateAgentRequest request, AgentInstances agentInstances, PluginRequest pluginRequest) {
34+
public CreateAgentRequestExecutor(CreateAgentRequest request, AgentInstances<KubernetesInstance> agentInstances, PluginRequest pluginRequest) {
3435
this.request = request;
3536
this.agentInstances = agentInstances;
3637
this.pluginRequest = pluginRequest;

src/main/java/cd/go/contrib/elasticagent/executors/ServerPingRequestExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626

2727
public class ServerPingRequestExecutor implements RequestExecutor {
2828

29-
private final AgentInstances agentInstances;
29+
private final AgentInstances<KubernetesInstance> agentInstances;
3030
private final PluginRequest pluginRequest;
3131

32-
public ServerPingRequestExecutor(AgentInstances agentInstances, PluginRequest pluginRequest) {
32+
public ServerPingRequestExecutor(AgentInstances<KubernetesInstance> agentInstances, PluginRequest pluginRequest) {
3333
this.agentInstances = agentInstances;
3434
this.pluginRequest = pluginRequest;
3535
}

src/main/java/cd/go/contrib/elasticagent/requests/CreateAgentRequest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package cd.go.contrib.elasticagent.requests;
1818

19-
import cd.go.contrib.elasticagent.AgentInstances;
20-
import cd.go.contrib.elasticagent.Constants;
21-
import cd.go.contrib.elasticagent.PluginRequest;
22-
import cd.go.contrib.elasticagent.RequestExecutor;
19+
import cd.go.contrib.elasticagent.*;
2320
import cd.go.contrib.elasticagent.executors.CreateAgentRequestExecutor;
2421
import cd.go.contrib.elasticagent.model.JobIdentifier;
2522
import com.google.gson.annotations.Expose;
@@ -82,7 +79,7 @@ public JobIdentifier jobIdentifier() {
8279
return jobIdentifier;
8380
}
8481

85-
public RequestExecutor executor(AgentInstances agentInstances, PluginRequest pluginRequest) {
82+
public RequestExecutor executor(AgentInstances<KubernetesInstance> agentInstances, PluginRequest pluginRequest) {
8683
return new CreateAgentRequestExecutor(this, agentInstances, pluginRequest);
8784
}
8885

src/main/java/cd/go/contrib/elasticagent/requests/ProfileValidateRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cd.go.contrib.elasticagent.RequestExecutor;
2020
import cd.go.contrib.elasticagent.executors.ProfileValidateRequestExecutor;
21-
import com.google.gson.Gson;
21+
import com.google.gson.reflect.TypeToken;
2222

2323
import java.util.Map;
2424

@@ -32,7 +32,8 @@ public ProfileValidateRequest(Map<String, String> properties) {
3232
}
3333

3434
public static ProfileValidateRequest fromJSON(String json) {
35-
return new ProfileValidateRequest(GSON.fromJson(json, Map.class));
35+
return new ProfileValidateRequest(GSON.fromJson(json, new TypeToken<Map<String, String>>() {
36+
}.getType()));
3637
}
3738

3839
public Map<String, String> getProperties() {

src/main/java/cd/go/contrib/elasticagent/requests/ShouldAssignWorkRequest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616

1717
package cd.go.contrib.elasticagent.requests;
1818

19-
import cd.go.contrib.elasticagent.Agent;
20-
import cd.go.contrib.elasticagent.AgentInstances;
21-
import cd.go.contrib.elasticagent.Request;
22-
import cd.go.contrib.elasticagent.RequestExecutor;
19+
import cd.go.contrib.elasticagent.*;
2320
import cd.go.contrib.elasticagent.executors.ShouldAssignWorkRequestExecutor;
2421
import cd.go.contrib.elasticagent.model.JobIdentifier;
2522
import com.google.gson.annotations.Expose;
@@ -75,7 +72,7 @@ public Map<String, String> properties() {
7572
return properties;
7673
}
7774

78-
public RequestExecutor executor(AgentInstances agentInstances) {
75+
public RequestExecutor executor(AgentInstances<KubernetesInstance> agentInstances) {
7976
return new ShouldAssignWorkRequestExecutor(this, agentInstances);
8077
}
8178

src/test/java/cd/go/contrib/elasticagent/executors/CreateAgentRequestExecutorTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
package cd.go.contrib.elasticagent.executors;
1818

19-
import cd.go.contrib.elasticagent.AgentInstances;
20-
import cd.go.contrib.elasticagent.PluginRequest;
21-
import cd.go.contrib.elasticagent.PluginSettings;
19+
import cd.go.contrib.elasticagent.*;
2220
import cd.go.contrib.elasticagent.requests.CreateAgentRequest;
2321
import org.junit.Test;
2422

@@ -28,7 +26,7 @@ public class CreateAgentRequestExecutorTest {
2826
@Test
2927
public void shouldAskDockerContainersToCreateAnAgent() throws Exception {
3028
CreateAgentRequest request = new CreateAgentRequest();
31-
AgentInstances agentInstances = mock(AgentInstances.class);
29+
AgentInstances<KubernetesInstance> agentInstances = mock(KubernetesAgentInstances.class);
3230
PluginRequest pluginRequest = mock(PluginRequest.class);
3331
PluginSettings settings = mock(PluginSettings.class);
3432
when(pluginRequest.getPluginSettings()).thenReturn(settings);

src/test/java/cd/go/contrib/elasticagent/executors/GetPluginConfigurationExecutorTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
package cd.go.contrib.elasticagent.executors;
1818

1919
import com.google.gson.Gson;
20+
import com.google.gson.reflect.TypeToken;
2021
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
2122
import org.junit.Test;
2223
import org.skyscreamer.jsonassert.JSONAssert;
2324

24-
import java.util.HashMap;
25+
import java.util.Map;
2526

2627
import static org.hamcrest.CoreMatchers.is;
2728
import static org.junit.Assert.assertEquals;
@@ -30,9 +31,10 @@
3031
public class GetPluginConfigurationExecutorTest {
3132

3233
@Test
33-
public void shouldSerializeAllFields() throws Exception {
34+
public void shouldSerializeAllFields() {
3435
GoPluginApiResponse response = new GetPluginConfigurationExecutor().execute();
35-
HashMap hashMap = new Gson().fromJson(response.responseBody(), HashMap.class);
36+
Map hashMap = new Gson().fromJson(response.responseBody(), new TypeToken<Map<String, Object>>() {
37+
}.getType());
3638
assertEquals("Are you using anonymous inner classes — see https://github.com/google/gson/issues/298",
3739
hashMap.size(),
3840
GetPluginConfigurationExecutor.FIELDS.size()

src/test/java/cd/go/contrib/elasticagent/executors/GetProfileMetadataExecutorTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616

1717
package cd.go.contrib.elasticagent.executors;
1818

19+
import cd.go.contrib.elasticagent.model.Field;
1920
import com.google.gson.Gson;
21+
import com.google.gson.reflect.TypeToken;
2022
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
2123
import org.junit.Test;
2224
import org.skyscreamer.jsonassert.JSONAssert;
@@ -31,7 +33,8 @@ public class GetProfileMetadataExecutorTest {
3133
@Test
3234
public void shouldSerializeAllFields() throws Exception {
3335
GoPluginApiResponse response = new GetProfileMetadataExecutor().execute();
34-
List list = new Gson().fromJson(response.responseBody(), List.class);
36+
List<Field> list = new Gson().fromJson(response.responseBody(), new TypeToken<List<Field>>() {
37+
}.getType());
3538
assertEquals(list.size(), GetProfileMetadataExecutor.FIELDS.size());
3639
}
3740

src/test/java/cd/go/contrib/elasticagent/executors/GetProfileViewExecutorTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
import cd.go.contrib.elasticagent.model.Metadata;
2020
import cd.go.contrib.elasticagent.utils.Util;
2121
import com.google.gson.Gson;
22+
import com.google.gson.reflect.TypeToken;
2223
import com.thoughtworks.go.plugin.api.response.GoPluginApiResponse;
2324
import org.jsoup.Jsoup;
2425
import org.jsoup.nodes.Document;
2526
import org.jsoup.select.Elements;
2627
import org.junit.Test;
2728

28-
import java.util.HashMap;
2929
import java.util.Map;
3030

3131
import static org.hamcrest.Matchers.*;
@@ -36,7 +36,8 @@ public class GetProfileViewExecutorTest {
3636
public void shouldRenderTheTemplateInJSON() throws Exception {
3737
GoPluginApiResponse response = new GetProfileViewExecutor().execute();
3838
assertThat(response.responseCode(), is(200));
39-
Map<String, String> hashSet = new Gson().fromJson(response.responseBody(), HashMap.class);
39+
Map<String, String> hashSet = new Gson().fromJson(response.responseBody(), new TypeToken<Map<String, String>>() {
40+
}.getType());
4041
assertThat(hashSet, hasEntry("template", Util.readResource("/profile.template.html")));
4142
}
4243

0 commit comments

Comments
 (0)