File tree Expand file tree Collapse file tree 11 files changed +74
-8
lines changed
src/main/java/io/toolisticon/pogen4selenium/api
java/io/toolisticon/pogen4selenium/processor/common
java/io/toolisticon/pogen4selenium/processor/pageobject
resources/testcases/pageobject/synchronized Expand file tree Collapse file tree 11 files changed +74
-8
lines changed Original file line number Diff line number Diff line change 99 <parent >
1010 <groupId >io.toolisticon.pogen4selenium</groupId >
1111 <artifactId >pogen4selenium</artifactId >
12- <version >0.11 .0</version >
12+ <version >0.12 .0</version >
1313 </parent >
1414
1515 <name >pogen4selenium-api</name >
Original file line number Diff line number Diff line change 1+ /**
2+ *
3+ */
4+ package io .toolisticon .pogen4selenium .api ;
5+
6+ import static java .lang .annotation .ElementType .METHOD ;
7+ import static java .lang .annotation .RetentionPolicy .RUNTIME ;
8+
9+ import java .lang .annotation .Documented ;
10+ import java .lang .annotation .Retention ;
11+ import java .lang .annotation .Target ;
12+
13+ @ Documented
14+ @ Retention (RUNTIME )
15+ @ Target (METHOD )
16+ /**
17+ * This annotation is used to enforce page objects method to be synchronized
18+ */
19+ public @interface Synchronized {
20+
21+ }
Original file line number Diff line number Diff line change 99 <parent >
1010 <groupId >io.toolisticon.pogen4selenium</groupId >
1111 <artifactId >pogen4selenium</artifactId >
12- <version >0.11 .0</version >
12+ <version >0.12 .0</version >
1313 </parent >
1414
1515 <name >pogen4selenium-example</name >
3333 <dependency >
3434 <groupId >io.toolisticon.pogen4selenium</groupId >
3535 <artifactId >pogen4selenium-api</artifactId >
36- <version >0.11 .0</version >
36+ <version >0.12 .0</version >
3737 </dependency >
3838
3939 <dependency >
Original file line number Diff line number Diff line change 33 <parent >
44 <artifactId >pogen4selenium</artifactId >
55 <groupId >io.toolisticon.pogen4selenium</groupId >
6- <version >0.10 .1-SNAPSHOT</version >
6+ <version >0.11 .1-SNAPSHOT</version >
77 </parent >
88 <modelVersion >4.0.0</modelVersion >
99 <artifactId >pogen4selenium-processor</artifactId >
Original file line number Diff line number Diff line change 99 <parent >
1010 <groupId >io.toolisticon.pogen4selenium</groupId >
1111 <artifactId >pogen4selenium</artifactId >
12- <version >0.11 .0</version >
12+ <version >0.12 .0</version >
1313 </parent >
1414
1515 <name >pogen4selenium-processor</name >
Original file line number Diff line number Diff line change 1616import io .toolisticon .aptk .tools .wrapper .TypeElementWrapper ;
1717import io .toolisticon .pogen4selenium .api .DataObject ;
1818import io .toolisticon .pogen4selenium .api .PageObject ;
19+ import io .toolisticon .pogen4selenium .api .Synchronized ;
1920import io .toolisticon .pogen4selenium .processor .common .actions .ActionHelper ;
2021import io .toolisticon .pogen4selenium .processor .common .actions .LocateActionHandler ;
2122import io .toolisticon .pogen4selenium .processor .pageobject .ExtractDataValueWrapper ;
@@ -38,6 +39,10 @@ public boolean returnsPageObject() {
3839 return returnTypeElement .isPresent () && returnTypeElement .get ().hasAnnotation (PageObject .class );
3940 }
4041
42+ public boolean isSynchronized () {
43+ return executableElementWrapper .hasAnnotation (Synchronized .class );
44+ }
45+
4146 public String getMethodSignature () {
4247 return this .executableElementWrapper .getMethodSignature ();
4348 }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public class ${ toImplementHelper.implementationClassName } extends DataObjectP
3838
3939!{ for method : methodsToImplement}
4040 @Override
41- public ${ method.methodSignature} {
41+ public ! { if method.isSynchronized } synchronized! { / if } ${ method.methodSignature} {
4242
4343 pause(Duration.ofMillis(${method.beforePause} L));
4444
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public class ${ toImplementHelper.implementationClassName } ${toImplementHelper.
5252 // implement methods
5353!{ for method : methodsToImplement}
5454 @Override
55- public ${ method.methodSignature} {
55+ public ! { if method.isSynchronized } synchronized! { / if } ${ method.methodSignature} {
5656
5757 pause(Duration.ofMillis(${method.beforePause} L));
5858
Original file line number Diff line number Diff line change 99import io .toolisticon .aptk .tools .MessagerUtils ;
1010import io .toolisticon .cute .Cute ;
1111import io .toolisticon .cute .CuteApi ;
12+ import io .toolisticon .cute .matchers .CoreGeneratedFileObjectMatchers ;
1213import io .toolisticon .pogen4selenium .processor .datatoextract .DataObjectProcessor ;
1314import io .toolisticon .pogen4selenium .processor .pageobject .PageObjectProcessor ;
1415
@@ -94,6 +95,19 @@ public void test_valid_withLocatorInActions() {
9495 .executeTest ();
9596 }
9697
98+ @ Test
99+ public void test_valid_withSynchronizedAction () {
100+
101+ compileTestBuilder
102+ .andSourceFiles ("testcases/pageobject/synchronized/TestcaseValidUsage.java" )
103+ .whenCompiled ()
104+ .thenExpectThat ()
105+ .compilationSucceeds ()
106+ .andThat ().generatedSourceFile ("io.toolisticon.pogen4selenium.processor.tests.LoginPageImpl" )
107+ .matches (CoreGeneratedFileObjectMatchers .createContainsSubstringsMatcher ("synchronized" ))
108+ .executeTest ();
109+ }
110+
97111 @ Test
98112 public void test_valid_example () {
99113
Original file line number Diff line number Diff line change 1+ package io .toolisticon .pogen4selenium .processor .tests ;
2+
3+ import io .toolisticon .cute .PassIn ;
4+ import io .toolisticon .pogen4selenium .api .ActionClick ;
5+ import io .toolisticon .pogen4selenium .api .ActionWrite ;
6+ import io .toolisticon .pogen4selenium .api ._By ;
7+ import io .toolisticon .pogen4selenium .api .ExtractDataValue ;
8+ import io .toolisticon .pogen4selenium .api .PageObject ;
9+ import io .toolisticon .pogen4selenium .api .PageObjectElement ;
10+ import io .toolisticon .pogen4selenium .api .PageObjectParent ;
11+ import io .toolisticon .pogen4selenium .api .Synchronized ;
12+
13+
14+ public class TestcaseValidUsage {
15+
16+ @ PageObject
17+ public interface LoginPage extends PageObjectParent <LoginPage >{
18+
19+
20+ @ ActionClick (by = _By .XPATH , value = "//button[@type='submit']" )
21+ @ Synchronized
22+ LoginPage clickSubmitButton ();
23+
24+ }
25+
26+ }
You can’t perform that action at this time.
0 commit comments