Skip to content

Commit 58e0138

Browse files
author
Manuel Perez Belmonte
committed
Fixed issue with generic cast
1 parent 9942dc0 commit 58e0138

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/main/java/io/elastest/ece/application/APIController.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
import org.springframework.web.bind.annotation.RequestParam;
1717

1818
import javax.annotation.PostConstruct;
19-
import java.util.ArrayList;
20-
import java.util.HashMap;
21-
import java.util.List;
22-
import java.util.Map;
19+
import java.util.*;
2320

2421
/**
2522
* Copyright (c) 2017. Zuercher Hochschule fuer Angewandte Wissenschaften
@@ -85,7 +82,7 @@ public String estimateTJob(String tJobDefinition, String tJobCostModel, Model mo
8582
Gson gson = new Gson();
8683
CostModel costModel = gson.fromJson(tJobCostModel, CostModel.class);
8784
// ArrayList<String> components = costModel.getComponents().get(Loader.getSettings().getServicesConstant());
88-
ArrayList<String> components = (ArrayList<String>) costModel.getComponents().get("Services");
85+
ArrayList<String> components = (ArrayList<String>) Arrays.asList(costModel.getComponents().get("Services"));
8986
for(String component : components){
9087
//TODO: Query ESM for each service Cost Model
9188
// CostModel componentCostModel = esmDirver.getServiceCostModel(component);
@@ -181,7 +178,7 @@ public String estimatePost(@RequestParam String testId, @RequestParam String cos
181178
if (costModelType.equalsIgnoreCase("ONDEMAND")) {
182179
Map<String, Double> fixCost = costModel.getFix_cost();
183180
Map<String, Double> varRate = costModel.getVar_rate();
184-
Map<String, Object> components = costModel.getComponents();
181+
Map<String, String[]> components = costModel.getComponents();
185182
Map<String, String> metadata = tJob.getMetadata();
186183

187184
logger.info("Adding all fix costs from the cost model.");

src/main/java/io/elastest/ece/model/CostModel.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CostModel {
3939
private Map<String, Double> var_rate;
4040

4141
@ElementCollection(fetch = FetchType.EAGER)
42-
private Map<String, Object> components;
42+
private Map<String, String[]> components;
4343

4444
private String description;
4545

@@ -52,7 +52,7 @@ public CostModel(String name, String type, Map fix_cost) {
5252
this.fix_cost = fix_cost;
5353
}
5454

55-
public CostModel(String name, String type, Map<String, Double> fix_cost, Map<String, Double> var_rate, Map<String, Object> components, String description) {
55+
public CostModel(String name, String type, Map<String, Double> fix_cost, Map<String, Double> var_rate, Map<String, String[]> components, String description) {
5656
this.name = name;
5757
this.type = type;
5858
this.fix_cost = fix_cost;
@@ -105,11 +105,11 @@ public void setVar_rate(Map<String, Double> var_rate) {
105105
this.var_rate = var_rate;
106106
}
107107

108-
public Map<String, Object> getComponents() {
108+
public Map<String, String[]> getComponents() {
109109
return components;
110110
}
111111

112-
public void setComponents(Map<String, Object> components) {
112+
public void setComponents(Map<String, String[]> components) {
113113
this.components = components;
114114
}
115115

0 commit comments

Comments
 (0)