Commit c3baee202487fbe3576603afacc2a71686b2daee

Authored by Nelson Torres Universidade U Minho
1 parent 2e97f5afb5
Exists in master

updated Lareferencia Tests

TestNGResources/Lrharvester/testng-lrharvester.xml
... ... @@ -7,19 +7,21 @@
7 7 <classes>
8 8  
9 9 <class name="testng.lrharvester.TestLoginLrharvester"/>
  10 +
10 11 <!--
11 12 <class name="testng.lrharvester.TestAddValidatorLrharvester"/>
  13 + -->
12 14 <class name="testng.lrharvester.TestAddNetworkLrharvester"/>
13 15 <class name="testng.lrharvester.TestAddOaiLrharvester"/>
14 16  
15 17 <class name="testng.lrharvester.TestHarvestFullLrharvester"/>
16 18 <class name="testng.lrharvester.TestTransformValidateFullLrharvester"/>
17   -
18 19 <class name="testng.lrharvester.TestAddDescargadeODLrharvester"/>
19   -
20 20 <class name="testng.lrharvester.TestIndexVufindLrharvester"/>
21   -
  21 + <!--
22 22 <class name="testng.lrharvester.TestIndexHistoricLrharvester"/>
  23 + <class name="testng.lrharvester.TestDeleteOaiLrharvester"/>
  24 + <class name="testng.lrharvester.TestDeleteNetworkLrharvester"/>
23 25 -->
24 26 </classes>
25 27 </test>
... ...
src/test/java/testng/lrharvester/TestAddDescargadeODLrharvester.java
... ... @@ -20,12 +20,13 @@ import java.util.concurrent.TimeUnit;
20 20 import static org.testng.Assert.assertTrue;
21 21  
22 22 public class TestAddDescargadeODLrharvester extends TestBase {
23   - String sURL = baseUrl + "/public/getRunningStatus";
  23 + String sURL;
24 24  
25 25  
26 26  
27 27 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
28 28 public void testAddValidator(String baseUrl) throws Exception {
  29 + sURL = baseUrl + "/public/getRunningStatus";
29 30 driver.get(baseUrl);
30 31 driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
31 32 acceptNextAlert = true;
... ... @@ -49,7 +50,6 @@ public class TestAddDescargadeODLrharvester extends TestBase {
49 50 );
50 51  
51 52 assertTrue(!isRunning());
52   - //TODO check BD alteration
53 53 }
54 54  
55 55 private boolean isRunning() throws IOException {
... ...
src/test/java/testng/lrharvester/TestAddNetworkLrharvester.java
... ... @@ -18,43 +18,70 @@ public class TestAddNetworkLrharvester extends TestBase {
18 18 driver.findElement(By.id("acronym")).click();
19 19 driver.findElement(By.id("acronym")).clear();
20 20 driver.findElement(By.id("acronym")).sendKeys("teste");
21   - driver.findElement(By.id("name")).click();
22 21 driver.findElement(By.id("name")).clear();
23 22 driver.findElement(By.id("name")).sendKeys("teste");
24   - driver.findElement(By.id("institutionAcronym")).click();
25 23 driver.findElement(By.id("institutionAcronym")).clear();
26 24 driver.findElement(By.id("institutionAcronym")).sendKeys("teste");
27   - driver.findElement(By.id("institutionName")).click();
28 25 driver.findElement(By.id("institutionName")).clear();
29 26 driver.findElement(By.id("institutionName")).sendKeys("teste");
30 27 driver.findElement(By.name("validator")).click();
31 28 new Select(driver.findElement(By.name("validator"))).selectByVisibleText("validator teste");
32   - driver.findElement(By.xpath("//option[@value='string:http://dev6.rcaap.pt/backend/rest/validator/1']")).click();
33   - driver.findElement(By.xpath("(//input[@value='Guardar cambios'])[2]")).click();
  29 + driver.findElement(By.xpath("//option[@value='string:http://dev6.rcaap.pt/backend/rest/validator/24']")).click();
  30 + driver.findElement(By.name("published")).click();
34 31 driver.findElement(By.linkText("Datos específicos")).click();
35   - driver.findElement(By.xpath("//div[2]/div/div/div[3]")).click();
36   - driver.findElement(By.id("type")).click();
  32 + driver.findElement(By.id("isni")).click();
  33 + driver.findElement(By.id("isni")).clear();
  34 + driver.findElement(By.id("isni")).sendKeys("teste");
  35 + driver.findElement(By.id("ringold")).clear();
  36 + driver.findElement(By.id("ringold")).sendKeys("teste");
37 37 driver.findElement(By.id("type")).clear();
38 38 driver.findElement(By.id("type")).sendKeys("teste");
39   - driver.findElement(By.id("software")).click();
40 39 driver.findElement(By.id("software")).clear();
41 40 driver.findElement(By.id("software")).sendKeys("teste");
42   - driver.findElement(By.id("description_pt")).click();
43 41 driver.findElement(By.id("description_pt")).clear();
44 42 driver.findElement(By.id("description_pt")).sendKeys("teste");
45   - driver.findElement(By.id("description_en")).click();
46 43 driver.findElement(By.id("description_en")).clear();
47 44 driver.findElement(By.id("description_en")).sendKeys("teste");
48   - driver.findElement(By.id("country")).click();
49 45 driver.findElement(By.id("country")).clear();
50 46 driver.findElement(By.id("country")).sendKeys("teste");
51   - driver.findElement(By.xpath("(//input[@value='Guardar cambios'])[4]")).click();
  47 + driver.findElement(By.id("directoryURL")).clear();
  48 + driver.findElement(By.id("directoryURL")).sendKeys("teste");
  49 + driver.findElement(By.id("oaiURL")).clear();
  50 + driver.findElement(By.id("oaiURL")).sendKeys("teste");
  51 + driver.findElement(By.id("roarMap")).clear();
  52 + driver.findElement(By.id("roarMap")).sendKeys("teste");
  53 + driver.findElement(By.id("openDoar")).clear();
  54 + driver.findElement(By.id("openDoar")).sendKeys("teste");
  55 + driver.findElement(By.id("sherpa")).clear();
  56 + driver.findElement(By.id("sherpa")).sendKeys("teste");
  57 + driver.findElement(By.id("eissn")).clear();
  58 + driver.findElement(By.id("eissn")).sendKeys("teste");
  59 + driver.findElement(By.id("pissn")).clear();
  60 + driver.findElement(By.id("pissn")).sendKeys("teste");
  61 + driver.findElement(By.id("issnL")).clear();
  62 + driver.findElement(By.id("issnL")).sendKeys("teste");
  63 + driver.findElement(By.id("handle")).clear();
  64 + driver.findElement(By.id("handle")).sendKeys("teste");
  65 + driver.findElement(By.linkText("Acciones")).click();
  66 + driver.findElement(By.xpath("//div[2]/label/span")).click();
  67 + driver.findElement(By.xpath("//div[3]/label/span")).click();
  68 + driver.findElement(By.xpath("//div[4]/label/span")).click();
  69 + driver.findElement(By.name("networkPropertiesEditForm")).click();
  70 + driver.findElement(By.xpath("//div[5]/label/span")).click();
  71 + driver.findElement(By.xpath("//div[3]/form/div[6]/label/span")).click();
  72 + driver.findElement(By.xpath("//div[7]/label/span")).click();
  73 + driver.findElement(By.xpath("//div[8]/label/span")).click();
  74 + driver.findElement(By.xpath("//div[9]/label/span")).click();
  75 + driver.findElement(By.xpath("//div[10]/label/span")).click();
  76 + driver.findElement(By.xpath("//div[14]/label/span")).click();
  77 + driver.findElement(By.xpath("(//input[@value='Guardar cambios'])[6]")).click();
52 78 driver.findElement(By.xpath("//div[2]/button")).click();
  79 +
  80 +
53 81 driver.findElement(By.name("acronym")).click();
54 82 driver.findElement(By.name("acronym")).clear();
55 83 driver.findElement(By.name("acronym")).sendKeys("teste");
56 84 assertEquals(driver.getTitle(), "LAReferencia - Administración");
57   - assertEquals(driver.findElement(By.xpath("//td[3]")).getText(), "1");
58 85 assertEquals(driver.findElement(By.xpath("//td[4]")).getText(), "teste");
59 86 assertEquals(driver.findElement(By.xpath("//td[5]")).getText(), "teste");
60 87 }
... ...
src/test/java/testng/lrharvester/TestAddOaiLrharvester.java
... ... @@ -6,6 +6,8 @@ import org.openqa.selenium.support.ui.Select;
6 6 import org.testng.annotations.Test;
7 7 import testng.rcaap.TestBase;
8 8  
  9 +import java.util.concurrent.TimeUnit;
  10 +
9 11 public class TestAddOaiLrharvester extends TestBase {
10 12  
11 13  
... ... @@ -13,9 +15,14 @@ public class TestAddOaiLrharvester extends TestBase {
13 15 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
14 16 public void testAddOai(String baseUrl) throws Exception {
15 17 driver.get(baseUrl);
  18 + driver.findElement(By.name("acronym")).click();
  19 + driver.findElement(By.name("acronym")).clear();
  20 + driver.findElement(By.name("acronym")).sendKeys("teste");
  21 + TimeUnit.SECONDS.sleep(5);
16 22 driver.findElement(By.xpath("//button[2]")).click();
  23 + TimeUnit.SECONDS.sleep(5);
17 24 driver.findElement(By.linkText("Nuevo origen")).click();
18   - driver.findElement(By.id("uri")).click();
  25 + TimeUnit.SECONDS.sleep(5);
19 26 driver.findElement(By.id("uri")).click();
20 27 driver.findElement(By.id("uri")).clear();
21 28 driver.findElement(By.id("uri")).sendKeys("http://arca.igc.gulbenkian.pt/oaiextended/request");
... ... @@ -24,6 +31,8 @@ public class TestAddOaiLrharvester extends TestBase {
24 31 driver.findElement(By.xpath("//option[@value='string:xoai']")).click();
25 32 driver.findElement(By.xpath("//input[@value='Guardar']")).click();
26 33 driver.findElement(By.xpath("//div[2]/div/button")).click();
  34 + TimeUnit.SECONDS.sleep(5);
  35 +
27 36 }
28 37  
29 38  
... ...
src/test/java/testng/lrharvester/TestDeleteNetworkLrharvester.java
... ... @@ -0,0 +1,93 @@
  1 +package testng.lrharvester;
  2 +
  3 +import com.google.gson.JsonArray;
  4 +import com.google.gson.JsonElement;
  5 +import com.google.gson.JsonObject;
  6 +import com.google.gson.JsonParser;
  7 +import dataproviders.DataProviderLaReferencia;
  8 +import org.openqa.selenium.By;
  9 +import org.openqa.selenium.support.ui.FluentWait;
  10 +import org.openqa.selenium.support.ui.Wait;
  11 +import org.testng.annotations.Test;
  12 +import testng.rcaap.TestBase;
  13 +
  14 +import java.io.IOException;
  15 +import java.io.InputStream;
  16 +import java.io.InputStreamReader;
  17 +import java.net.URL;
  18 +import java.net.URLConnection;
  19 +import java.util.concurrent.TimeUnit;
  20 +
  21 +import static org.testng.Assert.assertTrue;
  22 +
  23 +public class TestDeleteNetworkLrharvester extends TestBase {
  24 + String sURL ;
  25 +
  26 +
  27 +
  28 + @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
  29 + public void testDeleteNetworkFull(String baseUrl) throws Exception {
  30 + sURL = baseUrl + "/public/getRunningStatus";
  31 + driver.get("http://dev6.rcaap.pt/backend/home");
  32 + driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
  33 + acceptNextAlert = true;
  34 + driver.findElement(By.xpath("(//a[contains(text(),'Eliminar la red')])[2]")).click();
  35 +
  36 + assertTrue(closeAlertAndGetItsText().matches("^¿Está seguro de ejecutar Eliminar la red [\\s\\S]$"));
  37 +
  38 + Wait wait = new FluentWait(driver)
  39 + .withTimeout(3600, TimeUnit.SECONDS)
  40 + .pollingEvery(20, TimeUnit.SECONDS)
  41 + .ignoring(IOException.class);
  42 + TimeUnit.SECONDS.sleep(10);
  43 +
  44 + wait.until(o -> {
  45 + try {
  46 + return !isRunning();
  47 + } catch (IOException e) {
  48 + e.printStackTrace();
  49 + }
  50 + return false;
  51 + }
  52 + );
  53 +
  54 + }
  55 +
  56 + private boolean isRunning() throws IOException {
  57 +
  58 + URL url = new URL(sURL);
  59 + URLConnection request = url.openConnection();
  60 + request.connect();
  61 +
  62 + // Convert to a JSON object to print data
  63 + JsonParser jp = new JsonParser(); //from gson
  64 + JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent())); //Convert the input stream to a json element
  65 + JsonObject rootobj = root.getAsJsonObject(); //May be an array, may be an object.
  66 + JsonObject running = rootobj.getAsJsonObject("running");
  67 +
  68 + return running.size() > 0;
  69 + }
  70 +
  71 + private boolean isTransformed() throws IOException {
  72 +
  73 +
  74 + URL url = new URL(baseUrl + "/public/listSnapshotsByNetworkAcronym/teste");
  75 + URLConnection request = url.openConnection();
  76 + request.connect();
  77 +
  78 + // Convert to a JSON object to print data
  79 + JsonParser jp = new JsonParser(); //from gson
  80 + JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent())); //Convert the input stream to a json element
  81 + JsonArray rootobj = root.getAsJsonArray(); //May be an array, may be an object.
  82 +
  83 + JsonObject snapshotInfo = rootobj.get(rootobj.size() - 1).getAsJsonObject();
  84 +
  85 + int size = snapshotInfo.get("size").getAsInt();
  86 + int validSize = snapshotInfo.get("validSize").getAsInt();
  87 +
  88 + System.out.println("size: "+size+" validSize: "+validSize);
  89 +
  90 + return size > 0 && validSize >= 0 && validSize <= size;
  91 + }
  92 +
  93 +}
... ...
src/test/java/testng/lrharvester/TestDeleteOaiLrharvester.java
... ... @@ -0,0 +1,21 @@
  1 +package testng.lrharvester;
  2 +
  3 +import dataproviders.DataProviderLaReferencia;
  4 +import org.openqa.selenium.By;
  5 +import org.testng.annotations.Test;
  6 +import testng.rcaap.TestBase;
  7 +
  8 +public class TestDeleteOaiLrharvester extends TestBase {
  9 +
  10 + @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
  11 + public void testDeleteNetworkFull(String baseUrl) throws Exception {
  12 + driver.get(baseUrl);
  13 + driver.findElement(By.name("acronym")).click();
  14 + driver.findElement(By.name("acronym")).clear();
  15 + driver.findElement(By.name("acronym")).sendKeys("teste");
  16 + driver.findElement(By.xpath("//button[2]")).click();
  17 + driver.findElement(By.xpath("//button[2]")).click();
  18 +
  19 + }
  20 +
  21 +}
... ...
src/test/java/testng/lrharvester/TestHarvestFullLrharvester.java
... ... @@ -21,13 +21,17 @@ import java.util.concurrent.TimeUnit;
21 21 import static org.testng.Assert.assertTrue;
22 22  
23 23 public class TestHarvestFullLrharvester extends TestBase {
24   - String sURL = baseUrl + "/public/getRunningStatus";
  24 + String sURL;
  25 + String networkSnapshotsURL;
25 26 URL url;
26 27 URLConnection request;
27 28  
28 29  
29 30 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
30 31 public void testHarvestFull(String baseUrl) throws Exception {
  32 + sURL = baseUrl + "/public/getRunningStatus";
  33 + networkSnapshotsURL = baseUrl + "/public/listSnapshotsByNetworkAcronym/teste";
  34 +
31 35 driver.get(baseUrl);
32 36 driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
33 37 acceptNextAlert = true;
... ... @@ -71,7 +75,7 @@ public class TestHarvestFullLrharvester extends TestBase {
71 75  
72 76 private boolean isHarvested() throws IOException {
73 77  
74   - url = new URL(baseUrl + "/public/listSnapshotsByNetworkAcronym/teste");
  78 + url = new URL(networkSnapshotsURL);
75 79 request = url.openConnection();
76 80 request.connect();
77 81  
... ...
src/test/java/testng/lrharvester/TestIndexHistoricLrharvester.java
... ... @@ -20,11 +20,12 @@ import java.util.concurrent.TimeUnit;
20 20 import static org.testng.Assert.assertTrue;
21 21  
22 22 public class TestIndexHistoricLrharvester extends TestBase {
23   - String sURL = baseUrl + "/public/getRunningStatus";
  23 + String sURL;
24 24  
25 25  
26 26 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
27 27 public void testIndexHistoric(String baseUrl) throws Exception {
  28 + sURL = baseUrl + "/public/getRunningStatus";
28 29 driver.get(baseUrl);
29 30 driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
30 31 acceptNextAlert = true;
... ...
src/test/java/testng/lrharvester/TestIndexVufindLrharvester.java
... ... @@ -20,11 +20,14 @@ import java.util.concurrent.TimeUnit;
20 20 import static org.testng.Assert.assertTrue;
21 21  
22 22 public class TestIndexVufindLrharvester extends TestBase {
23   - String sURL = baseUrl + "/public/getRunningStatus";
24   -
  23 + String sURL;
  24 + String solrUrl;
  25 + String networkID;
25 26  
26 27 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
27 28 public void testIndexVufindFull(String baseUrl) throws Exception {
  29 + sURL = baseUrl + "/public/getRunningStatus";
  30 + solrUrl = "http://dev6.rcaap.pt/solr/coreTest/select?ident=on&q=network_acronym_str:teste&wt=json";
28 31 driver.get(baseUrl);
29 32 driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
30 33 acceptNextAlert = true;
... ... @@ -47,6 +50,21 @@ public class TestIndexVufindLrharvester extends TestBase {
47 50 }
48 51 );
49 52  
  53 +
  54 + driver.get(baseUrl);
  55 + driver.findElement(By.name("acronym")).click();
  56 + driver.findElement(By.name("acronym")).clear();
  57 + driver.findElement(By.name("acronym")).sendKeys("teste");
  58 + driver.findElement(By.xpath("//td[3]")).click();
  59 +
  60 + networkID = driver.findElement(By.xpath("//td[3]")).getText();
  61 +
  62 +
  63 +
  64 +
  65 +
  66 +
  67 +
50 68 assertTrue(isIndexed());
51 69 }
52 70  
... ... @@ -67,11 +85,11 @@ public class TestIndexVufindLrharvester extends TestBase {
67 85  
68 86 private boolean isIndexed() throws IOException {
69 87  
70   - URL url = new URL("http://dev6.rcaap.pt/solr/coreTest/select?ident=on&q=network_acronym_str:teste&wt=json");
  88 + URL url = new URL(solrUrl);
71 89 URLConnection request = url.openConnection();
72 90 request.connect();
73 91  
74   - // Convert to a JSON object to print data
  92 +
75 93 JsonParser jp = new JsonParser(); //from gson
76 94 JsonElement root = jp.parse(new InputStreamReader((InputStream) request.getContent())); //Convert the input stream to a json element
77 95 JsonObject rootobj = root.getAsJsonObject(); //May be an array, may be an object.
... ... @@ -79,20 +97,10 @@ public class TestIndexVufindLrharvester extends TestBase {
79 97 JsonObject response= rootobj.get("response").getAsJsonObject();
80 98 int numFound = response.get("numFound").getAsInt();
81 99  
82   - url = new URL("http://dev6.rcaap.pt/backend/private/networks?count=1&filter[teste]=CC&page=1");
83   - request = url.openConnection();
84   - request.connect();
85   - jp = new JsonParser();
86   - root = jp.parse(new InputStreamReader((InputStream) request.getContent()));
87   - rootobj = root.getAsJsonObject();
88   - JsonObject network = rootobj.get("networks").getAsJsonObject();
89   - String networkID = network.get("networkID").getAsString();
90   -
91 100  
92 101 url = new URL("http://dev6.rcaap.pt/backend/public/lastGoodKnowSnapshotByNetworkID/"+ networkID);
93 102 request = url.openConnection();
94 103 request.connect();
95   - jp = new JsonParser(); //from gson
96 104 root = jp.parse(new InputStreamReader((InputStream) request.getContent())); //Convert the input stream to a json element
97 105 rootobj = root.getAsJsonObject(); //May be an array, may be an object.
98 106  
... ...
src/test/java/testng/lrharvester/TestTransformValidateFullLrharvester.java
... ... @@ -21,12 +21,14 @@ import java.util.concurrent.TimeUnit;
21 21 import static org.testng.Assert.assertTrue;
22 22  
23 23 public class TestTransformValidateFullLrharvester extends TestBase {
24   - String sURL = baseUrl + "/public/getRunningStatus";
25   -
  24 + String sURL ;
  25 + String networkSnapshotURL ;
26 26  
27 27  
28 28 @Test( dataProvider = "development", dataProviderClass = DataProviderLaReferencia.class)
29 29 public void testTransformValidateFull(String baseUrl) throws Exception {
  30 + sURL = baseUrl + "/public/getRunningStatus";
  31 + networkSnapshotURL = baseUrl + "/public/listSnapshotsByNetworkAcronym/teste";
30 32 driver.get(baseUrl);
31 33 driver.findElement(By.xpath("(//button[@type='button'])[3]")).click();
32 34 acceptNextAlert = true;
... ... @@ -70,7 +72,7 @@ public class TestTransformValidateFullLrharvester extends TestBase {
70 72 private boolean isTransformed() throws IOException {
71 73  
72 74  
73   - URL url = new URL(baseUrl + "/public/listSnapshotsByNetworkAcronym/teste");
  75 + URL url = new URL(networkSnapshotURL);
74 76 URLConnection request = url.openConnection();
75 77 request.connect();
76 78  
... ...