Skip to content

Commit

Permalink
TEST refs #31 : tests for Main
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaël NOGUÈS committed Jul 27, 2016
1 parent e24ecd9 commit 8e3b069
Show file tree
Hide file tree
Showing 28 changed files with 321 additions and 318 deletions.
4 changes: 2 additions & 2 deletions avek-gui/sandbox/src/main/java/sandbox/SubjectJsonGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import fr.axonic.avek.gui.model.json.Jsonifier;
import fr.axonic.avek.gui.model.sample.ExampleState;
import fr.axonic.avek.gui.model.sample.ExampleStateBool;
import fr.axonic.avek.gui.model.structure.ExperimentationResults;
import fr.axonic.avek.gui.model.structure.ExperimentationResultsMap;
import fr.axonic.avek.model.MonitoredSystem;
import fr.axonic.avek.model.base.ADate;
import fr.axonic.avek.model.base.ANumber;
Expand Down Expand Up @@ -62,7 +62,7 @@ private static String generateSubject() {
}

public static String generateParameters() throws VerificationException {
ExperimentationResults expRes = new ExperimentationResults();
ExperimentationResultsMap expRes = new ExperimentationResultsMap();

{ ARangedEnum<ExampleState> aEnum = new ARangedEnum<>(ExampleState.VERY_LOW);
aEnum.setRange(Arrays.asList(ExampleState.values()));
Expand Down
28 changes: 7 additions & 21 deletions avek-gui/src/main/java/fr/axonic/avek/gui/Main.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package fr.axonic.avek.gui;

import fr.axonic.avek.gui.util.ConcurrentTaskManager;
import fr.axonic.avek.gui.util.Util;
import fr.axonic.avek.gui.view.GeneralizedView;
import fr.axonic.avek.gui.view.MainFrame;
import javafx.application.Application;
import javafx.scene.Scene;
Expand All @@ -14,39 +11,28 @@
public class Main extends Application {
private final static Logger logger = Logger.getLogger(Main.class);

private MainFrame mainFrame;

public static void main(String[] args) {
launch(args);
}


@Override
public void start(Stage primaryStage) throws IOException {
ConcurrentTaskManager ctm = new ConcurrentTaskManager();

logger.debug("Loading MainFrame...");

primaryStage.setTitle("#AVEK analyzer");

MainFrame mainFrame = new MainFrame();
mainFrame = new MainFrame();
Scene s = new Scene(mainFrame, 800, 600);
primaryStage.setScene(s);

primaryStage.show();
logger.debug("MainFrame created.");


ctm.runLaterOnThread(() -> {
try {
GeneralizedView generalizedView = new GeneralizedView();
Thread.sleep(2000);
ctm.runLaterOnPlatform(() -> mainFrame.setView(generalizedView));
Thread.sleep(2000);
ctm.runLaterOnPlatform(() -> generalizedView.setMonitoredSystem(Util.getFileContent("files/subjectFile.json")));
Thread.sleep(2000);
ctm.runLaterOnPlatform(() -> generalizedView.setExperimentParameters(Util.getFileContent("files/parametersFile.json")));
} catch (Exception e) {
e.printStackTrace();
}
});
}

MainFrame getMainFrame() {
return mainFrame;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class JellyBean extends HBox {
private Object expEffect;
private JellyBeansSelector mainController;

// should be public
public JellyBean() {
FXMLLoader fxmlLoader = new FXMLLoader(FXML);
fxmlLoader.setRoot(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.axonic.avek.gui.components.results;

import fr.axonic.avek.gui.model.json.Jsonifier;
import fr.axonic.avek.gui.model.structure.ExpEffect;
import fr.axonic.avek.gui.model.structure.ExperimentationResults;
import fr.axonic.avek.gui.model.structure.ExperimentationResult;
import fr.axonic.avek.gui.model.structure.ExperimentationResultsMap;
import fr.axonic.avek.gui.util.Util;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -38,7 +38,7 @@ public class JellyBeansSelector extends VBox {
@FXML
private FlowPane jellyBeansPane;
@FXML
private ComboBox<ExpEffect> comboBoxJellyBean;
private ComboBox<ExperimentationResult> comboBoxJellyBean;

private final Set<String> addedEffects;

Expand All @@ -65,7 +65,7 @@ public JellyBeansSelector() {

// Fill experiment sample list
String results = Util.getFileContent("files/resultEnum1.json");
ExperimentationResults expr = new Jsonifier<>(ExperimentationResults.class).fromJson(results);
ExperimentationResultsMap expr = new Jsonifier<>(ExperimentationResultsMap.class).fromJson(results);
setJellyBeansChoice(FXCollections.observableArrayList(expr.getList()));
}

Expand All @@ -90,12 +90,12 @@ void onNewExpEffectClicked(ActionEvent event) {
*/
private void updateJellyBeanChoice() {
comboBoxJellyBean.setCellFactory(
new Callback<ListView<ExpEffect>, ListCell<ExpEffect>>() {
new Callback<ListView<ExperimentationResult>, ListCell<ExperimentationResult>>() {
@Override
public ListCell<ExpEffect> call(ListView<ExpEffect> param) {
return new ListCell<ExpEffect>() {
public ListCell<ExperimentationResult> call(ListView<ExperimentationResult> param) {
return new ListCell<ExperimentationResult>() {
@Override
public void updateItem(ExpEffect item, boolean empty) {
public void updateItem(ExperimentationResult item, boolean empty) {
super.updateItem(item, empty);
if (item != null) {
setText(item.getName());
Expand All @@ -111,7 +111,7 @@ public void updateItem(ExpEffect item, boolean empty) {

private void addJellyBean() {
// Verify if JellyBean already created (this result is already selected)
ExpEffect choice = comboBoxJellyBean.getValue();
ExperimentationResult choice = comboBoxJellyBean.getValue();
if (choice == null) {
logger.warn("Choice is null");
return;
Expand All @@ -135,7 +135,7 @@ void removeJellyBean(JellyBean jbc) {
updateJellyBeanChoice();
}

public void setJellyBeansChoice(ObservableList<ExpEffect> items) {
void setJellyBeansChoice(ObservableList<ExperimentationResult> items) {
this.comboBoxJellyBean.setItems(items);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
/**
* Created by Nathaël N on 07/07/16.
*/
public class ExpEffect {
public class ExperimentationResult {
private final ARangedEnum states;
private final String name;

public ExpEffect(String name, ARangedEnum aEnum) {
this.states = aEnum;
public ExperimentationResult(String name, ARangedEnum states) {
this.states = states;
this.name = name;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.axonic.avek.gui.model.structure;

import fr.axonic.avek.model.base.ARangedEnum;

import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;

/**
* Created by Nathaël N on 12/07/16.
*/
public class ExperimentationResultsMap extends HashMap<String, ARangedEnum> {

public List<ExperimentationResult> getList() {
return keySet().stream()
.map(s -> new ExperimentationResult(s, get(s)))
.collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ public double getPct() {
public boolean equals(Object obj) {
if (obj instanceof UploadedFile)
return origin.equals(((UploadedFile) obj).origin);
if (obj instanceof File)
return origin.equals(obj) || uploaded.equals(obj);
return super.equals(obj);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private <V> void run(Callable<V> c, boolean onPlatform) {
try {
c.call();
} catch (Exception e) {
e.printStackTrace();
logger.error("Exception thrown during task call", e);
}
return;
}
Expand Down
8 changes: 0 additions & 8 deletions avek-gui/src/main/java/fr/axonic/avek/gui/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,4 @@ public static String getFileContent(String path) {
}
return res;
}

public static void disableGraphics() {
System.setProperty("testfx.robot", "glass");
System.setProperty("prism.order", "sw");
System.setProperty("testfx.headless", "true");
System.setProperty("java.awt.headless", "true");
System.setProperty("prism.text", "t2k");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ void onClicStrategyButton(ActionEvent event) {
*
* @param monitoredSystemJson the MonitoredSystem as a Json String
*/
void setMonitoredSystem(String monitoredSystemJson) {
public void setMonitoredSystem(String monitoredSystemJson) {
monitoredSystemPane.setMonitoredSystem(MonitoredSystem.fromJson(monitoredSystemJson));
}

void setExperimentParameters(String experimentParametersJson) {
public void setExperimentParameters(String experimentParametersJson) {
AList<AEntity> list = Jsonifier.toAListofAListAndAVar(experimentParametersJson);

for (AEntity ae : list.getEntities())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
package fr.axonic.avek.gui.view;

import fr.axonic.avek.gui.components.MonitoredSystemPane;
import fr.axonic.avek.gui.components.parameters.GeneralizedParametersPane;
import fr.axonic.avek.gui.components.results.JellyBeansSelector;
import fr.axonic.avek.gui.model.json.Jsonifier;
import fr.axonic.avek.gui.model.structure.ExpEffect;
import fr.axonic.avek.model.MonitoredSystem;
import fr.axonic.avek.model.base.engine.AEntity;
import fr.axonic.avek.model.base.engine.AList;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.util.Callback;
import org.apache.log4j.Logger;

import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
Expand Down
4 changes: 2 additions & 2 deletions avek-gui/src/main/java/fr/axonic/avek/gui/view/TreatView.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ void onClicStrategyButton(ActionEvent event) {
*
* @param monitoredSystemJson the MonitoredSystem as a Json String
*/
void setMonitoredSystem(String monitoredSystemJson) {
public void setMonitoredSystem(String monitoredSystemJson) {
monitoredSystemPane.setMonitoredSystem(MonitoredSystem.fromJson(monitoredSystemJson));
}

void setExperimentParameters(String experimentParametersJson) {
public void setExperimentParameters(String experimentParametersJson) {
AList<AEntity> list = Jsonifier.toAListofAListAndAVar(experimentParametersJson);

for (AEntity ae : list.getEntities())
Expand Down
2 changes: 1 addition & 1 deletion avek-gui/src/main/resources/files/parametersFile.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"label": "SubNumber"
},
{
"value": "Jul 25, 2016 9:50:31 AM",
"value": "Jul 27, 2016 11:21:54 AM",
"format": {
"formatType": "DATE"
},
Expand Down
Loading

0 comments on commit 8e3b069

Please sign in to comment.