use of org.jboss.tools.cdi.reddeer.validators.ValidationProblem in project jbosstools-integration-tests by jbosstools.
the class ValidationHelper method findProblems.
public List<Problem> findProblems(ValidationProblem validationProblem) {
StringContains regexpMatcher = new StringContains(validationProblem.getMessage());
MarkerDescriptionMatcher descriptionMatcher = new MarkerDescriptionMatcher(regexpMatcher);
List<Problem> filteredProblems = new ArrayList<Problem>();
try {
/**
* Sometimes happens that marker is displayed and suddenly is hidden and displayed again,
* so it is better to wait and doublecheck.
*/
new WaitUntil(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.LONG);
new WaitWhile(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.getCustom(5), false);
new WaitUntil(new ProblemExists(validationProblem.getProblemType(), descriptionMatcher), TimePeriod.DEFAULT);
ProblemsView pw = new ProblemsView();
pw.open();
new WaitUntil(new ProblemExists(ProblemType.ALL), TimePeriod.MEDIUM, false);
filteredProblems = pw.getProblems(validationProblem.getProblemType(), descriptionMatcher);
} catch (WaitTimeoutExpiredException ex) {
log.warn(validationProblem.toString() + " not found.");
}
logProblemViewStatus(filteredProblems);
return filteredProblems;
}
use of org.jboss.tools.cdi.reddeer.validators.ValidationProblem in project jbosstools-integration-tests by jbosstools.
the class StereotypeValidationQuickFixTemplate method testTargetAnnotation.
// https://issues.jboss.org/browse/JBIDE-7630
// cdi 1.0, not for 1.1+
@Test
public void testTargetAnnotation() {
String className = "Stereotype1";
beansHelper.createStereotype(className, getPackageName(), false, false, false, false, false);
editResourceUtil.replaceInEditor(className + ".java", "@Target({ TYPE, METHOD, FIELD })", "@Target({ TYPE, FIELD })");
ValidationProblem problem = validationProvider.getValidationProblem(ValidationType.TARGET);
List<Problem> problems = validationHelper.findProblems(problem);
if (CDIVersion.equals("1.0")) {
assertEquals(1, problems.size());
validationHelper.openQuickfix(problem, 3);
TextEditor te = new TextEditor();
te.getText().contentEquals("@Target({TYPE, METHOD, FIELD})");
editResourceUtil.replaceInEditor(className + ".java", "@Target({TYPE, METHOD, FIELD})", "");
problems = validationHelper.findProblems(problem);
assertEquals(1, problems.size());
} else {
assertEquals(0, problems.size());
editResourceUtil.replaceInEditor(className + ".java", "@Target({ TYPE, FIELD })", "");
problems = validationHelper.findProblems(problem);
assertEquals(0, problems.size());
}
}
use of org.jboss.tools.cdi.reddeer.validators.ValidationProblem in project jbosstools-integration-tests by jbosstools.
the class StereotypeValidationQuickFixTemplate method testNamedAnnotation.
// https://issues.jboss.org/browse/JBIDE-7634
@Test
public void testNamedAnnotation() {
String className = "Stereotype3";
beansHelper.createStereotype(className, getPackageName(), false, false, false, false, false);
editResourceUtil.replaceClassContentByResource(className + ".java", readFile("resources/quickfix/stereotype/StereotypeWithNamed.java.cdi"), false);
editResourceUtil.replaceInEditor(className + ".java", "StereotypeComponent", className);
ValidationProblem problem = validationProvider.getValidationProblem(ValidationType.NAMED);
List<Problem> problems = validationHelper.findProblems(problem);
assertEquals(1, problems.size());
validationHelper.openQuickfix(problem);
new WaitWhile(new ProblemExists(ProblemType.ALL));
}
use of org.jboss.tools.cdi.reddeer.validators.ValidationProblem in project jbosstools-integration-tests by jbosstools.
the class ExcludeBeanTemplate method testExcludedBeans.
@Test
public void testExcludedBeans() {
NewClassCreationWizard jd = new NewClassCreationWizard();
jd.open();
NewClassWizardPage jp = new NewClassWizardPage(jd);
jp.setName("TestExcluded");
jp.setPackage("test");
jd.finish();
TextEditor ed = new TextEditor("TestExcluded.java");
editResourceUtil.replaceClassContentByResource("TestExcluded.java", readFile("resources/excluded/TestExcluded.jav_"), false);
String warning = "org.eclipse.ui.workbench.texteditor.warning";
new WaitUntil(new EditorHasValidationMarkers(ed));
List<Marker> markers = ed.getMarkers();
assertEquals(3, markers.size());
ValidationProblem expected = validationProvider.getValidationProblem(ValidationType.NO_BEAN_ELIGIBLE);
for (Marker m : ed.getMarkers()) {
// JBIDE-26664
String expectedJSRVersion = expected.getJSR();
if (CDIVersion.equals("1.2")) {
expectedJSRVersion = "JSR-365";
}
assertTrue((m.getLineNumber() == 16 && m.getType().equals(warning) && m.getText().contains(expected.getMessage()) && m.getText().contains(expectedJSRVersion)) || (m.getLineNumber() == 18 && m.getType().equals(warning) && m.getText().contains(expected.getMessage()) && m.getText().contains(expectedJSRVersion)) || (m.getLineNumber() == 19 && m.getType().equals(warning) && m.getText().contains(expected.getMessage()) && m.getText().contains(expectedJSRVersion)));
}
ProblemsView pw = new ProblemsView();
pw.open();
assertEquals(3, pw.getProblems(ProblemType.ALL).size());
List<Problem> foundProblems = validationHelper.findProblems(expected);
assertEquals(3, foundProblems.size());
}
use of org.jboss.tools.cdi.reddeer.validators.ValidationProblem in project jbosstools-integration-tests by jbosstools.
the class BeansXMLUITemplate method setAndCheckSourceDiscoveryMode.
private void setAndCheckSourceDiscoveryMode(EditorPartWrapper beans, String mode, ValidationType... expectedProblems) {
beans.activateTreePage();
String currentMode = beans.getBeanDiscoveryMode();
beans.activateSourcePage();
editResourceUtil.replaceInEditor("beans.xml", currentMode, mode);
Editor e = new DefaultEditor();
if (expectedProblems.length > 0) {
for (ValidationType validationType : expectedProblems) {
ValidationProblem expectedProblem = validationProvider.getValidationProblem(validationType);
List<Problem> foundProblems = validationHelper.findProblems(expectedProblem);
assertTrue(expectedProblem + " not found. There are these markers: " + e.getMarkers(), foundProblems.size() == 1);
}
} else {
new WaitUntil(new EditorHasValidationMarkers(e), TimePeriod.DEFAULT, false);
new WaitWhile(new EditorHasValidationMarkers(e), TimePeriod.LONG, false);
}
beans.activateTreePage();
assertEquals(mode, beans.getBeanDiscoveryMode());
}
Aggregations