Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.4.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>compile</scope>
</dependency>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[14,22] package io.restassured does not exist [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[15,27] package io.restassured.http does not exist [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[16,31] package io.restassured.response does not exist [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[17,17] package org.junit does not exist [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[19,29] package io.restassured does not exist [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[19,1] static import only from classes and interfaces [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[20,24] cannot find symbol symbol: class Assert location: package org.junit [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[38,6] cannot find symbol symbol: class Before location: class com.medeiros.RoostTest.transactionsGetTest [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[49,11] cannot find symbol symbol: variable RestAssured location: class com.medeiros.RoostTest.transactionsGetTest [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[51,17] cannot find symbol symbol: class Response location: class com.medeiros.RoostTest.transactionsGetTest [ERROR] /C:/Program Files/Go/src/github.com/API-MusicBlender-Java/src/test/java/com/medeiros/RoostTest/transactionsGetTest.java:[51,37] cannot find symbol symbol: method given() location: class com.medeiros.RoostTest.transactionsGetTest 

The added dependencies were missing.

FIX :- Added the necessary dependencies needed for the imports.


</dependencies>

Expand Down
111 changes: 111 additions & 0 deletions src/test/java/com/medeiros/RoostTest/TestdataLoader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

package com.medeiros.RoostTest;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Arrays;

public class TestdataLoader {

private String fromENV(String name) {
return System.getenv(name);
}

private String fromPropertiesFile(String name) {
Properties properties = new Properties();
try (InputStream input = getClass().getClassLoader().getResourceAsStream("application.properties")) {
if (input == null) {
System.out.println("Sorry, unable to find application.properties");
return null;
}
properties.load(input);
return properties.getProperty(name);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

private List<Map<String, String>> fromCSVFile(String filePath) {
List<Map<String, String>> data = new ArrayList<>();

try (BufferedReader br = new BufferedReader(new FileReader(filePath))) {
String line;
boolean headerSkipped = false;
List<String> headers = new ArrayList<>();

while ((line = br.readLine()) != null) {
if (!headerSkipped) {
headers.addAll(List.of(line.split(",")));
headerSkipped = true;
continue;
}

String[] values = line.split(",");
if (values.length > 0) {
Map<String, String> row = new HashMap<>();
for (int i = 0; i < Math.min(headers.size(), values.length); i++) {
row.put(headers.get(i), values[i].trim());
}
data.add(row);
}
}
} catch (IOException e) {
e.printStackTrace();
}

return data;
}

public List<Map<String, String>> loadData(String csvFileName) {
Map<String, String> envMap = new HashMap<>();
List<Map<String, String>> csvData = this.fromCSVFile(csvFileName);
Map<String, String> envMapwithCSV = new HashMap<>();
List<Map<String, String>> envVars = new ArrayList<>();
String[] envVarsList = this.getEnvVariableList(csvFileName);

for (String key : envVarsList) {
envMap.put(key, "");
String value = this.fromENV(key);
if (value != null) {
envMap.put(key, value);
}
value = this.fromPropertiesFile(key);
if (value != null) {
envMap.put(key, value);
}
}
for (Map<String, String> row : csvData) {
envMapwithCSV.putAll(envMap);
for (Map.Entry<String, String> entry : row.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (!value.equals("")) {
envMapwithCSV.put(key, value);
}
}
envVars.add(envMapwithCSV);
}
return envVars;
}

private String[] getEnvVariableList(String csvFileName) {
String[] envVars = { "BASE_URL", "API_KEY" };
try (BufferedReader reader = new BufferedReader(new FileReader(csvFileName))) {
String headerLine = reader.readLine();
String[] csvHeaders = headerLine.split(",");
String[] finalEnvArray = Arrays.copyOfRange(envVars, 0, envVars.length + csvHeaders.length);
System.arraycopy(csvHeaders, 0, finalEnvArray, envVars.length, csvHeaders.length);
return finalEnvArray;
} catch (IOException e) {
e.printStackTrace();
}
return envVars;
}
}
11 changes: 11 additions & 0 deletions src/test/java/com/medeiros/RoostTest/transactionsGetTest.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
company,from,offset,limit,statusCode
23495,2023-11-27T11:28:37+01:00,0,25,200
38492,2024-05-15T10:18:23+01:00,10,15,200
57843,2022-12-30T15:45:12+01:00,20,30,200
12984,2025-01-20T09:30:45+01:00,30,20,200
64921,2023-06-10T08:25:50+01:00,40,10,200
39284,2022-08-01T07:14:35+01:00,50,5,200
28493,2024-02-28T16:38:29+01:00,60,40,200
94823,2025-07-25T13:52:41+01:00,70,35,200
58392,2023-03-15T12:46:53+01:00,80,45,200
49238,2022-09-10T11:41:06+01:00,90,50,200
65 changes: 65 additions & 0 deletions src/test/java/com/medeiros/RoostTest/transactionsGetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// ********RoostGPT********
/*
Test generated by RoostGPT for test ReatAssured-Test using AI Type Open AI and AI Model gpt-4

Test generated for /api/customer/transactions_get for http method type GET in rest-assured framework

RoostTestHash=c35c7610a4


*/

// ********RoostGPT********
package com.medeiros.RoostTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import org.junit.Before;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import org.hamcrest.MatcherAssert;
import static org.hamcrest.Matchers.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class transactionsGetTest {

List<Map<String, String>> envList = new ArrayList<>();


@Before
public void setUp() {
TestdataLoader dataloader = new TestdataLoader();
envList = dataloader.loadData("src/test/java/com/medeiros/RoostTest/transactionsGetTest.csv");
}


@Test
public void transactionsGet_Test() {
this.setUp();
for (Map<String, String> map : envList) {
RestAssured.baseURI = map.get("BASE_URL");

Response response = given()
.queryParam("company", map.get("company") != null ? map.get("company") : "")
.header("Authorization", "Bearer " + map.get("AUTH_TOKEN"))
.when()
.get("/api/customer/transactions")
.then()
.extract().response();

if (response.statusCode() == 200) {
System.out.println("Description: Get CustomerTransaction");
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.medeiros.SPRINGProject;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
// import org.junit.jupiter.api.Test;
// import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class SpringProjectApplicationTests {
// @SpringBootTest
// class SpringProjectApplicationTests {

@Test
void contextLoads() {
}
// @Test
// void contextLoads() {
// }

}
// }