-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ETS-TAF/feature/selenium
Feature/selenium
- Loading branch information
Showing
35 changed files
with
1,193 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
/.idea | ||
/k8s | ||
/pulumi | ||
/selenium | ||
/testapi | ||
/tests-ui | ||
/frontend/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
backend/src/main/java/ca/etsmtl/taf/apiCommunication/SeleniumServiceRequester.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ca.etsmtl.taf.apiCommunication; | ||
|
||
import ca.etsmtl.taf.dto.SeleniumCaseDto; | ||
import ca.etsmtl.taf.entity.SeleniumActionRequest; | ||
import ca.etsmtl.taf.entity.SeleniumCaseResponse; | ||
import ca.etsmtl.taf.entity.SeleniumTestCase; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class SeleniumServiceRequester { | ||
private final WebClient webClient; | ||
|
||
@Autowired | ||
public SeleniumServiceRequester(WebClient webClient) { | ||
this.webClient = webClient; | ||
} | ||
|
||
public Mono<SeleniumCaseResponse> sendTestCase(SeleniumCaseDto testCase) { | ||
return webClient.post() | ||
.uri("/microservice/selenium/test") | ||
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.body(Mono.just(testCase), SeleniumCaseDto.class) | ||
.retrieve() | ||
.bodyToMono(SeleniumCaseResponse.class); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/ca/etsmtl/taf/config/WebConfigSelenium.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package ca.etsmtl.taf.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.reactive.function.client.WebClient; | ||
|
||
@Configuration | ||
public class WebConfigSelenium { | ||
|
||
@Value("${taf.app.selenium_container_url}") | ||
String SELENIUM_CONTAINER_URL; | ||
|
||
@Value("${taf.app.selenium_container_port}") | ||
String SELENIUM_CONTAINER_PORT; | ||
|
||
@Bean | ||
public WebClient webClient() { | ||
return WebClient.builder() | ||
.baseUrl(SELENIUM_CONTAINER_URL + ":" + SELENIUM_CONTAINER_PORT) | ||
.defaultCookie("cookie-name", "cookie-value") | ||
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) | ||
.build(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/ca/etsmtl/taf/controller/TestSeleniumController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ca.etsmtl.taf.controller; | ||
|
||
import ca.etsmtl.taf.dto.SeleniumCaseDto; | ||
import ca.etsmtl.taf.entity.SeleniumCaseResponse; | ||
import ca.etsmtl.taf.service.SeleniumService; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.List; | ||
|
||
@CrossOrigin(origins = "*", maxAge = 3600) | ||
@RestController | ||
@RequestMapping("/api") | ||
public class TestSeleniumController { | ||
private final SeleniumService seleniumService; | ||
|
||
public TestSeleniumController(SeleniumService seleniumService) { | ||
this.seleniumService = seleniumService; | ||
} | ||
|
||
@PostMapping("/testselenium") | ||
public ResponseEntity<List<SeleniumCaseResponse>> runTests(@RequestBody List<SeleniumCaseDto> seleniumCases) throws URISyntaxException, IOException, InterruptedException { | ||
List<SeleniumCaseResponse> response = seleniumService.sendTestCases(seleniumCases); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/ca/etsmtl/taf/dto/SeleniumCaseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ca.etsmtl.taf.dto; | ||
|
||
import ca.etsmtl.taf.entity.SeleniumActionRequest; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class SeleniumCaseDto { | ||
int case_id; | ||
String caseName; | ||
List<SeleniumActionRequest> actions; | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/src/main/java/ca/etsmtl/taf/entity/SeleniumActionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package ca.etsmtl.taf.entity; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class SeleniumActionRequest { | ||
int action_id; | ||
int action_type_id; | ||
String action_type_name; | ||
String object; | ||
String input; | ||
String target; | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/main/java/ca/etsmtl/taf/entity/SeleniumCaseResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ca.etsmtl.taf.entity; | ||
|
||
import lombok.Data; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
@Data | ||
public class SeleniumCaseResponse implements Serializable { | ||
int case_id; | ||
String caseName; | ||
public List<SeleniumActionRequest> seleniumActions; | ||
public boolean success; | ||
public long timestamp; | ||
public long duration; | ||
public String output; | ||
} |
10 changes: 10 additions & 0 deletions
10
backend/src/main/java/ca/etsmtl/taf/entity/SeleniumTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package ca.etsmtl.taf.entity; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class SeleniumTestCase { | ||
List<SeleniumActionRequest> seleniumActionRequestList; | ||
} |
31 changes: 31 additions & 0 deletions
31
backend/src/main/java/ca/etsmtl/taf/service/SeleniumService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ca.etsmtl.taf.service; | ||
|
||
import ca.etsmtl.taf.apiCommunication.SeleniumServiceRequester; | ||
import ca.etsmtl.taf.dto.SeleniumCaseDto; | ||
import ca.etsmtl.taf.entity.SeleniumActionRequest; | ||
import ca.etsmtl.taf.entity.SeleniumCaseResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
public class SeleniumService { | ||
private final SeleniumServiceRequester seleniumServiceRequester; | ||
|
||
public SeleniumService(SeleniumServiceRequester seleniumServiceRequester) { | ||
this.seleniumServiceRequester = seleniumServiceRequester; | ||
} | ||
|
||
public List<SeleniumCaseResponse> sendTestCases(List<SeleniumCaseDto> seleniumCases) throws URISyntaxException, IOException, InterruptedException { | ||
List<SeleniumCaseResponse> testResults = new ArrayList<>(); | ||
for(SeleniumCaseDto seleniumCaseDto : seleniumCases) { | ||
|
||
SeleniumCaseResponse testCaseResult = seleniumServiceRequester.sendTestCase(seleniumCaseDto).block(); | ||
testResults.add(testCaseResult); | ||
} | ||
return testResults; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.showModelResult{ | ||
width: 100%; background-color: rgba(0, 0, 0, 0.4); height: 100vh;position: absolute;left: 0;top: 0; z-index: 9999; | ||
} | ||
|
||
.hideIt{ | ||
visibility: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.