This is an automated email from the ASF dual-hosted git repository.

ofuks pushed a commit to branch feature-integration-tests
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/feature-integration-tests by 
this push:
     new af3fea4  Fixed issue with endpoint feature; added project scenario
af3fea4 is described below

commit af3fea420342e5ee26f16d64d4850be69eaaf53d
Author: Oleh Fuks <olegfuk...@gmail.com>
AuthorDate: Fri Jan 3 12:50:01 2020 +0200

    Fixed issue with endpoint feature; added project scenario
---
 .../java/org/apache/dlab/util/PropertyHelper.java  |  2 +-
 .../src/test/java/dlab/endpoint/EndpointSteps.java | 14 +++++++----
 .../src/test/java/dlab/project/ProjectSteps.java   | 27 ++++++++++++++++------
 .../src/test/resources/config.properties           |  6 ++---
 .../src/test/resources/dlab/endpoint.feature       | 17 +++++++-------
 .../src/test/resources/dlab/project.feature        | 11 +++++++++
 6 files changed, 54 insertions(+), 23 deletions(-)

diff --git 
a/integration-tests-cucumber/src/main/java/org/apache/dlab/util/PropertyHelper.java
 
b/integration-tests-cucumber/src/main/java/org/apache/dlab/util/PropertyHelper.java
index d575ff0..cee9a89 100644
--- 
a/integration-tests-cucumber/src/main/java/org/apache/dlab/util/PropertyHelper.java
+++ 
b/integration-tests-cucumber/src/main/java/org/apache/dlab/util/PropertyHelper.java
@@ -14,7 +14,7 @@ public class PropertyHelper {
        static {
                PROPERTIES = new Properties();
 
-               try (InputStream inputStream = new 
FileInputStream(System.getProperty("config.file"))) {
+               try (InputStream inputStream = new 
FileInputStream("/Users/ofuks/work/gitwork/incubator-dlab/integration-tests-cucumber/src/test/resources/config.properties"))
 {
                        PROPERTIES.load(inputStream);
                        log.info("Configs: {}", PROPERTIES);
                } catch (Exception e) {
diff --git 
a/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java 
b/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
index 316e521..79bb0b0 100644
--- a/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
+++ b/integration-tests-cucumber/src/test/java/dlab/endpoint/EndpointSteps.java
@@ -13,7 +13,11 @@ import org.apache.dlab.util.JacksonMapper;
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
+import static org.junit.Assert.assertTrue;
 import static com.jayway.restassured.RestAssured.given;
 import static dlab.Constants.API_URI;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -82,10 +86,12 @@ public class EndpointSteps {
 
        @And("There are endpoints with name test1 and test2")
        public void thereAreEndpointsWithNameTestAndTest() {
-               final EndpointDTO[] endpoints = 
response.getBody().as(EndpointDTO[].class);
-               assertThat(2, equalTo(endpoints.length));
-               assertThat("test1", equalTo(endpoints[0].getName()));
-               assertThat("test2", equalTo(endpoints[1].getName()));
+               List<String> endpoints = 
Arrays.stream(response.getBody().as(EndpointDTO[].class))
+                               .map(EndpointDTO::getName)
+                               .collect(Collectors.toList());
+
+               assertTrue(endpoints.contains("test1"));
+               assertTrue(endpoints.contains("test2"));
        }
 
        @And("Remove endpoint with name {string}")
diff --git 
a/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java 
b/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
index 2caefb7..8aa7a4f 100644
--- a/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
+++ b/integration-tests-cucumber/src/test/java/dlab/project/ProjectSteps.java
@@ -23,11 +23,7 @@ import org.apache.http.HttpStatus;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.time.LocalDateTime;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -134,8 +130,12 @@ public class ProjectSteps {
        @And("User tries to terminate the project with name {string}")
        public void userTriesToTerminateTheProjectWithName(String projectName) {
                this.projectName = projectName;
-               request = authenticatedRequest()
-                               .contentType(ContentType.JSON);
+               request = authenticatedRequest().contentType(ContentType.JSON);
+       }
+
+       @And("User tries to get information about projects")
+       public void userTriesToGetInformationAboutProjects() {
+               request = authenticatedRequest().contentType(ContentType.JSON);
        }
 
        @When("User sends create new project request")
@@ -158,6 +158,11 @@ public class ProjectSteps {
                response = request.delete(API_URI + "project/{project}", 
projectName);
        }
 
+       @When("User sends request to get information about projects")
+       public void userSendsRequestToGetInformationAboutProjects() {
+               response = request.get(API_URI + "project");
+       }
+
        @Then("Status code is {int}")
        public void statusCodeIs(int code) {
                assertThat(response.getStatusCode(), equalTo(code));
@@ -201,6 +206,14 @@ public class ProjectSteps {
                log.info("Project {} successfully edited", projectName);
        }
 
+
+       @And("Projects are successfully returned")
+       public void projectsAreSuccessfullyReturned() {
+               List<ProjectDTO> projects = 
Arrays.asList(response.getBody().as(ProjectDTO[].class));
+
+               assertTrue(projects.stream().anyMatch(p -> 
projectName.equals(p.getName())));
+       }
+
        private boolean waitForStatus(int timeout, EndpointStatusDTO.Status 
status) throws URISyntaxException, InterruptedException {
                boolean correctStatus = false;
                LocalDateTime withTimeout = 
LocalDateTime.now().plusMinutes(timeout);
diff --git a/integration-tests-cucumber/src/test/resources/config.properties 
b/integration-tests-cucumber/src/test/resources/config.properties
index 626d7a4..073f652 100644
--- a/integration-tests-cucumber/src/test/resources/config.properties
+++ b/integration-tests-cucumber/src/test/resources/config.properties
@@ -4,6 +4,6 @@ http.connection.timeout=5000
 http.socket.timeout=3000
 
 keycloak.serverUrl=http://52.11.45.11:8080/auth
-keycloak.realm=dlab
-keycloak.clientId=bhliva1012a-ui
-keycloak.clientSecret=83025cea-4121-42ea-9044-f5539fbe857f
\ No newline at end of file
+keycloak.realm=DLAB_bhliva
+keycloak.clientId=sss
+keycloak.clientSecret=cf5a484b-039b-4161-8707-ad65c0f25962
\ No newline at end of file
diff --git 
a/integration-tests-cucumber/src/test/resources/dlab/endpoint.feature 
b/integration-tests-cucumber/src/test/resources/dlab/endpoint.feature
index 5967715..ad4435a 100644
--- a/integration-tests-cucumber/src/test/resources/dlab/endpoint.feature
+++ b/integration-tests-cucumber/src/test/resources/dlab/endpoint.feature
@@ -1,3 +1,4 @@
+@endpoint
 Feature: Endpoint management in DLab
   Such feature allowed to manage endpoint inside DLab
 
@@ -10,8 +11,8 @@ Feature: Endpoint management in DLab
     And Endpoint URI is present in location header
     And Remove endpoint with name "<name>"
     Examples:
-      | name          | uri     | account   | tag      |
-      | test_endpoint | someuri | 123231312 | some_tag |
+      | name          | uri                     | account   | tag      |
+      | test_endpoint | https://localhost:8084/ | 123231312 | some_tag |
 
 
   Scenario Outline: Create new endpoint when it exist already
@@ -24,8 +25,8 @@ Feature: Endpoint management in DLab
     Then Response status code is 409
     And Remove endpoint with name "<name>"
     Examples:
-      | name          | uri     | account   | tag      |
-      | test_endpoint | someuri | 123231312 | some_tag |
+      | name          | uri                     | account   | tag      |
+      | test_endpoint | https://localhost:8084/ | 123231312 | some_tag |
 
 
   Scenario Outline: Get information for endpoint
@@ -38,17 +39,17 @@ Feature: Endpoint management in DLab
     And Endpoint information is successfully returned with name "<name>", uri 
"<uri>", account "<account>", and tag "<tag>"
     And Remove endpoint with name "<name>"
     Examples:
-      | name          | uri     | account   | tag      |
-      | test_endpoint | someuri | 123231312 | some_tag |
+      | name          | uri                     | account   | tag      |
+      | test_endpoint | https://localhost:8084/ | 123231312 | some_tag |
 
 
   Scenario: Get list of endpoints
 
     Given There is no endpoint with name "test1" in DLab
     Given There is no endpoint with name "test2" in DLab
-    And User try to create new endpoint with name "test1" and uri "someuri1" 
and account "123" and "customTag1"
+    And User try to create new endpoint with name "test1" and uri 
"https://localhost:8084/"; and account "123" and "customTag1"
     And  User send create new endpoint request
-    And User try to create new endpoint with name "test2" and uri "someuri2" 
and account "1233" and "customTag4"
+    And User try to create new endpoint with name "test2" and uri 
"https://localhost:8084/"; and account "1233" and "customTag4"
     And  User send create new endpoint request
     When User try to get information about endpoints
     Then Response status code is 200
diff --git a/integration-tests-cucumber/src/test/resources/dlab/project.feature 
b/integration-tests-cucumber/src/test/resources/dlab/project.feature
index 5aa0051..ea9477c 100644
--- a/integration-tests-cucumber/src/test/resources/dlab/project.feature
+++ b/integration-tests-cucumber/src/test/resources/dlab/project.feature
@@ -61,6 +61,17 @@ Feature: Project management in DLab
     Then Status code is 404
 
 
+  Scenario Outline: Get information about a project that does not exists
+
+    Given There is a project with name "<name>" in DLab
+    And User tries to get information about projects
+    When User sends request to get information about projects
+    Then Status code is 200
+    And Projects are successfully returned
+    Examples:
+      | name |
+      | prj1 |
+
   Scenario: Edit (change use shared image) a project that is available
 
     Given There is a project with name "prj1" in DLab


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to