Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSystem features to support work with new Difido design #373

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jsystem-archetypes/jsystem-so-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jsystemtest.archetypes</groupId>
<artifactId>jsystem-archetypes</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
Expand Down
2 changes: 1 addition & 1 deletion jsystem-archetypes/jsystem-tests-archetype/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jsystemtest.archetypes</groupId>
<artifactId>jsystem-archetypes</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
Expand Down
4 changes: 2 additions & 2 deletions jsystem-archetypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../jsystem-parent</relativePath>
</parent>
<properties>
<jsystem.version>6.1.12-SNAPSHOT</jsystem.version>
<jsystem.version>6.1.13-SNAPSHOT</jsystem.version>
</properties>
<modules>
<module>jsystem-so-archetype</module>
Expand Down
2 changes: 1 addition & 1 deletion jsystem-assembly/jsystem-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../../jsystem-parent</relativePath>
</parent>
<artifactId>jsystem-runner</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jsystem-core-projects/jsystem-launcher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../../jsystem-parent</relativePath>
</parent>
<artifactId>jsystem-launcher</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion jsystem-core-projects/jsystemAgent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../../jsystem-parent</relativePath>
</parent>
<artifactId>jsystemAgent</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import javax.management.NotificationListener;

import jsystem.framework.fixture.Fixture;
import jsystem.framework.report.DefaultReporterImpl.ReportLevel;
import jsystem.framework.report.JSystemListeners;
import jsystem.framework.report.ReportElement;
import jsystem.framework.report.Reporter;
Expand Down Expand Up @@ -448,4 +449,65 @@ public void flushReporters() {

}


@Override
public void jira(String title, String jiraId) {
report(title + EnumBadge.JIRA.setText(jiraId).get());
}

@Override
public void info(String title, String info) {
report(title + EnumBadge.INFO.setText(info).get());
}

@Override
public void info(String title) {
report(title + EnumBadge.INFO.setText(EnumBadge.INFO.name().toLowerCase()).get());
}

@Override
public void workaround(String title) {
report(title + EnumBadge.WORKAROUND.get());
}

@Override
public void debug(String title) {
report(title + EnumBadge.DEBUG.get());
}

@Override
public void bug(String title) {
report(title + EnumBadge.BUG.get());
}

@Override
public void result(String title, int status) {
report(title + EnumBadge.RESULT.get(), status);
}

@Override
public void result(String title) {
result(title, Reporter.PASS);
}

@Override
public void result(String title, boolean status) {
result(title, status ? Reporter.PASS : Reporter.FAIL);
}

@Override
public void result(String title, ReportAttribute reportAttribute) {
report(title + EnumBadge.RESULT.get(), reportAttribute);
}

@Override
public ReportLevel reportLevel(String level) {
return (ReportLevel) invokeMethod("reportLevel", new Object[]{level},new Class[]{String.class});
}

@Override
public ReportLevel reportLevel(String level, EnumBadge badge) {
return (ReportLevel) invokeMethod("reportLevel", new Object[]{level,badge},new Class[]{String.class,EnumBadge.class});
}

}
2 changes: 1 addition & 1 deletion jsystem-core-projects/jsystemAnt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../../jsystem-parent</relativePath>
</parent>
<artifactId>jsystemAnt</artifactId>
Expand Down
7 changes: 5 additions & 2 deletions jsystem-core-projects/jsystemApp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jsystemtest</groupId>
<artifactId>jsystem-parent</artifactId>
<version>6.1.12-SNAPSHOT</version>
<version>6.1.13-SNAPSHOT</version>
<relativePath>../../jsystem-parent</relativePath>
</parent>
<artifactId>jsystemApp</artifactId>
Expand All @@ -26,7 +26,10 @@
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
</dependency>

<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package jsystem.extensions.paramproviders;

import java.awt.Component;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;

import jsystem.framework.TestBeanClass;
import jsystem.framework.scenario.Parameter;
import jsystem.framework.scenario.RunnerTest;
import jsystem.framework.scenario.Scenario;
import jsystem.framework.scenario.UseDefaultDataModel;
import jsystem.treeui.utilities.ParameterProviderListener;
import jsystem.utils.beans.BeanElement;
import jsystem.utils.beans.BeanUtils;

public class CsvObjectArrayParameterProvider extends ObjectArrayParameterProvider {
private List<ParameterProviderListener> listenersList = new ArrayList<ParameterProviderListener>();

@Override
public synchronized Object showUI(Component parent, Scenario currentScenario, RunnerTest rtest, Class<?> classType,
Object object, Parameter parameter) throws Exception {
if (!classType.isArray()) {
throw new RuntimeException("ObjectArrayParameter must be of array type! current type is : " + classType);
}
ArrayList<BeanElement> beanElements = BeanUtils.getBeans(classType.getComponentType(), true, true,
BeanUtils.getBasicTypes());

ArrayList<LinkedHashMap<String, String>> multiMap = new ArrayList<LinkedHashMap<String, String>>();

if (object != null) {
Object[] array = null;
try {
array = (Object[]) object;
} catch (ClassCastException e) {
throw new RuntimeException("ObjectArrayParameter got wrong parameter! expected array type, got: "
+ object.getClass() + ", with value: " + object);
}

for (int i = 0; i < array.length; i++) {
Properties oProperties = BeanUtils.objectToProperties(array[i], beanElements);
multiMap.add(propertiesToMapBeanOrder(oProperties, beanElements));
}
}
// the user can specified using <code>TestBeanClass</code> annotation
// new data model class.
TestBeanClass tbc = classType.getComponentType().getAnnotation(TestBeanClass.class);
BeanCellEditorModel beanCellEditorModel = null;
if (tbc != null) {
// create the new data model
Class<?> modelClass = tbc.model();
if (!modelClass.equals(UseDefaultDataModel.class)) {
Constructor<?> cons = modelClass.getConstructor(beanElements.getClass(), multiMap.getClass());
if (cons != null) {
Object dataModel = cons.newInstance(beanElements, multiMap);
if (dataModel instanceof BeanCellEditorModel) {
beanCellEditorModel = (BeanCellEditorModel) dataModel;
}
}
}
}
CsvPropertiesDialog dialog = new CsvPropertiesDialog(multiMap, "Bean properties", beanElements,
propertiesToMapBeanOrder(
BeanUtils.objectToProperties(classType.getComponentType().newInstance(), beanElements),
beanElements), beanCellEditorModel, parameter.isEditable());
dialog.setModalityType(ModalityType.APPLICATION_MODAL);
dialog.setListeners(listenersList);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;

dialog.setBounds(new Rectangle(0, screenHeight / 10, screenWidth, screenHeight * 3 / 4));

if (dialog.showAndWaitForApprove()) {
Object[] array = (Object[]) Array.newInstance(classType.getComponentType(), multiMap.size());
for (int i = 0; i < array.length; i++) {
array[i] = BeanUtils.propertiesToObject(classType.getComponentType(), multiMap.get(i));
}
return array;
}
return object;
}

private static LinkedHashMap<String, String> propertiesToMapBeanOrder(Properties properties,
ArrayList<BeanElement> elements) {
LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
for (BeanElement be : elements) {
String value = properties.getProperty(be.getName());
if (value != null) {
map.put(be.getName(), value);
}
}
return map;
}

}
Loading