Skip to content

Commit 9942dc0

Browse files
author
Manuel Perez Belmonte
committed
Added api for torm to request an estimation of a tJob using a Cost Model
1 parent afa48fd commit 9942dc0

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ definitions:
186186
EstimateBody:
187187
type: object
188188
properties:
189-
testId:
189+
tJobDefinition:
190190
type: string
191-
costModelId:
191+
tJobCostModel:
192192
type: string
193193
FixCost:
194194
type: object

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
5+
import io.elastest.ece.load.Loader;
56
import io.elastest.ece.model.CostModel;
67
import io.elastest.ece.model.TJob;
78
import io.elastest.ece.persistance.HibernateClient;
@@ -79,6 +80,20 @@ public String getEstimateCostModels(Model model) {
7980
return "estimate";
8081
}
8182

83+
@RequestMapping(value = "/estimate", method = RequestMethod.POST)
84+
public String estimateTJob(String tJobDefinition, String tJobCostModel, Model model){
85+
Gson gson = new Gson();
86+
CostModel costModel = gson.fromJson(tJobCostModel, CostModel.class);
87+
// ArrayList<String> components = costModel.getComponents().get(Loader.getSettings().getServicesConstant());
88+
ArrayList<String> components = (ArrayList<String>) costModel.getComponents().get("Services");
89+
for(String component : components){
90+
//TODO: Query ESM for each service Cost Model
91+
// CostModel componentCostModel = esmDirver.getServiceCostModel(component);
92+
// estimatePost(tJobDefinition, componentCostModel);
93+
}
94+
return "";
95+
}
96+
8297
@RequestMapping(value = "/deletecostmodel", method = RequestMethod.GET)
8398
public String getDeleteCostModel(Model model) {
8499
logger.info("Creating test values.");
@@ -166,7 +181,7 @@ public String estimatePost(@RequestParam String testId, @RequestParam String cos
166181
if (costModelType.equalsIgnoreCase("ONDEMAND")) {
167182
Map<String, Double> fixCost = costModel.getFix_cost();
168183
Map<String, Double> varRate = costModel.getVar_rate();
169-
Map<String, String> components = costModel.getComponents();
184+
Map<String, Object> components = costModel.getComponents();
170185
Map<String, String> metadata = tJob.getMetadata();
171186

172187
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, String> components;
42+
private Map<String, Object> 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, String> components, String description) {
55+
public CostModel(String name, String type, Map<String, Double> fix_cost, Map<String, Double> var_rate, Map<String, Object> 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, String> getComponents() {
108+
public Map<String, Object> getComponents() {
109109
return components;
110110
}
111111

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

0 commit comments

Comments
 (0)