Skip to content

Commit

Permalink
[SPARKTA-436] add new testsAT for feature implemented in 198]
Browse files Browse the repository at this point in the history
  • Loading branch information
aalfonso-stratio committed Feb 18, 2016
1 parent 8a83a49 commit f2362b3
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.stratio.sparta.testsAT.automated.gui.policies;

import org.testng.annotations.Factory;
import org.testng.annotations.Test;

import com.stratio.cucumber.testng.CucumberRunner;
import com.stratio.data.BrowsersDataProvider;
import com.stratio.sparta.testsAT.utils.BaseTest;

import cucumber.api.CucumberOptions;

@CucumberOptions(features = { "src/test/resources/features/automated/gui/policies/addAutoFragmentCreation.feature" })
public class AddAutoFragmentCreation extends BaseTest {

@Factory(enabled = false, dataProviderClass = BrowsersDataProvider.class, dataProvider = "availableUniqueBrowsers")
public AddAutoFragmentCreation(String browser) {
this.browser = browser;
}

@Test(enabled = true, groups = {"web"})
public void checkElementsTest() throws Exception {
new CucumberRunner(this.getClass()).runCukes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,26 @@ Feature: Test all Get operations for policyContexts in Sparta Swagger API

Scenario: Get all policyContexts when one available
Given I send a 'POST' request to '/policyContext' based on 'schemas/policies/policy.conf' as 'json' with:
| name | UPDATE | policy1 |
| name | UPDATE | policyContextAvailable |
| fragments | DELETE | N/A |
| outputs[1] | DELETE | N/A |
| id | DELETE | N/A |
Then the service response status must be '200' and its response must contain the text '"policyName":"policy1"'
Then the service response status must be '200' and its response must contain the text '"policyName":"policyContextAvailable"'
And I save element '$.policyId' in attribute 'previousPolicyID'
When I send a 'GET' request to '/policyContext'
Then the service response status must be '200' and its response must contain the text '"id":"!{previousPolicyID}"'

Scenario: Clean up
When I send a 'DELETE' request to '/policy/!{previousPolicyID}'
Then the service response status must be '200'.

# Delete fragments
When I send a 'GET' request to '/fragment/input/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID'
When I send a 'DELETE' request to '/fragment/input/!{previousFragmentID}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Feature: Test all POST operations for policyContexts in Sparta Swagger API
| name | UPDATE | policyContextValid |
| fragments | DELETE | N/A |
| id | DELETE | N/A |
Then the service response status must be '500' and its response must contain the text 'policyContextValid already exists'
Then the service response status must be '404' and its response must contain the text 'Can't create policy'

Scenario: Add a policyContext with existing fragment
When I send a 'POST' request to '/policyContext' based on 'schemas/policies/policy.conf' as 'json' with:
Expand Down Expand Up @@ -177,4 +177,31 @@ Feature: Test all POST operations for policyContexts in Sparta Swagger API
Then the service response status must be '200' and its response length must be '1'
# Delete policy created with first policyContext
When I send a 'DELETE' request to '/policy/!{previousPolicyID}'
Then the service response status must be '200'.
Then the service response status must be '200'.

# Delete fragments
When I send a 'GET' request to '/fragment/input/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID'
When I send a 'DELETE' request to '/fragment/input/!{previousFragmentID}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/input/name/elementname'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID'
When I send a 'DELETE' request to '/fragment/input/!{previousFragmentID}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name2'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/elementname'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,20 @@ Feature: Test all PUT operations for policyContexts in Sparta Swagger API

Scenario: Clean up
When I send a 'DELETE' request to '/policy/!{previousPolicyID}'
Then the service response status must be '200'.
Then the service response status must be '200'.
# Delete fragments
When I send a 'GET' request to '/fragment/input/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID'
When I send a 'DELETE' request to '/fragment/input/!{previousFragmentID}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name2'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
@web @rest
Feature: Test adding a new policy in Sparta GUI

Background: Setup Sparta GUI
Given I set web base url to '${SPARTA_HOST}:${SPARTA_PORT}'
Given I send requests to '${SPARTA_HOST}:${SPARTA_API_PORT}'

Scenario: Add a new policy through api
When I send a 'POST' request to '/policyContext' based on 'schemas/policies/policy.conf' as 'json' with:
| name | UPDATE | policy1 |
| fragments | DELETE | N/A |
| outputs[1] | DELETE | N/A |
| id | DELETE | N/A |
Then the service response status must be '200'.
And I save element '$.policyId' in attribute 'previousPolicyID'
# Check that is listed
When I send a 'GET' request to '/policy/all'
Then the service response status must be '200' and its response length must be '1'
# Check that input has been created
When I send a 'GET' request to '/fragment/input'
Then the service response status must be '200' and its response length must be '1'
# Check that output has been created
When I send a 'GET' request to '/fragment/output'
Then the service response status must be '200' and its response length must be '1'

# Browse to policies
Given I browse to '/#/dashboard/policies'
Then I wait '2' seconds
And '1' element exists with 'css:i[data-qa^="policy-context-menu-"]'

# Browse to inputs
Given I browse to '/#/dashboard/inputs'
Then I wait '2' seconds
And '1' element exists with 'css:span[data-qa^="input-context-menu-"]'
# Try to edit input
Then I click on the element on index '0'
And I wait '1' second
Given '1' element exists with 'css:st-menu-element[data-qa$="-edit"]'
When I click on the element on index '0'
Then I wait '1' second
And '1' element exists with 'css:aside[data-qa="fragment-details-modal"]'
# Modify
Given '1' element exists with 'css:button[data-qa="modal-ok-button"]'
When I click on the element on index '0'

# Browse to outputs
Given I browse to '/#/dashboard/outputs'
Then I wait '2' seconds
And '1' element exists with 'css:span[data-qa^="output-context-menu-"]'
# Try to edit output
Then I click on the element on index '0'
And I wait '1' second
Given '1' element exists with 'css:st-menu-element[data-qa$="-edit"]'
When I click on the element on index '0'
Then I wait '1' second
And '1' element exists with 'css:aside[data-qa="fragment-details-modal"]'
# Modify
Given '1' element exists with 'css:button[data-qa="modal-ok-button"]'
When I click on the element on index '0'

# Add same policy with different name, fragments should be reused
When I send a 'POST' request to '/policyContext' based on 'schemas/policies/policy.conf' as 'json' with:
| name | UPDATE | policy2 |
| fragments | DELETE | N/A |
| outputs[1] | DELETE | N/A |
| id | DELETE | N/A |
Then the service response status must be '200'.
And I save element '$.policyId' in attribute 'previousPolicyID_2'

# Browse to inputs
Given I browse to '/#/dashboard/inputs'
Then I wait '2' seconds
And '1' element exists with 'css:span[data-qa^="input-context-menu-"]'

# Browse to outputs
Given I browse to '/#/dashboard/outputs'
Then I wait '2' seconds
And '1' element exists with 'css:span[data-qa^="output-context-menu-"]'

# Delete policy
When I send a 'DELETE' request to '/policy/!{previousPolicyID}'
Then the service response status must be '200'.
When I send a 'DELETE' request to '/policy/!{previousPolicyID_2}'
Then the service response status must be '200'.
When I send a 'GET' request to '/policy/all'
Then the service response status must be '200' and its response must contain the text '[]'

# Delete fragments
When I send a 'GET' request to '/fragment/input/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID'
When I send a 'DELETE' request to '/fragment/input/!{previousFragmentID}'
Then the service response status must be '200'.
When I send a 'GET' request to '/fragment/output/name/name'
Then the service response status must be '200'.
And I save element '$.id' in attribute 'previousFragmentID_2'
When I send a 'DELETE' request to '/fragment/output/!{previousFragmentID_2}'
Then the service response status must be '200'.

0 comments on commit f2362b3

Please sign in to comment.