Commit de866dd0 authored by s174270's avatar s174270
Browse files

empty transaction list report

parent 9e216689
Loading
Loading
Loading
Loading
+47 −1
Original line number Original line Diff line number Diff line
@@ -13,6 +13,8 @@ import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.cucumber.java.en.When;
import models.DTUPayUser;
import models.DTUPayUser;
import org.acme.models.*;
import org.acme.models.*;
import org.acme.resources.ReportResource;
import org.eclipse.persistence.queries.ReportQuery;
import org.jboss.resteasy.spi.NotImplementedYetException;
import org.jboss.resteasy.spi.NotImplementedYetException;
import org.junit.Assert;
import org.junit.Assert;


@@ -36,9 +38,9 @@ public class MySteps {
    String bankId;
    String bankId;
    String type;
    String type;
    String error;
    String error;
    List<String> tokens;


    public HttpResponse<String> response;
    public HttpResponse<String> response;
    private List<String> transactions = new ArrayList<>();




    @Given("the costumer {string} has {int} unused tokens")
    @Given("the costumer {string} has {int} unused tokens")
@@ -335,6 +337,50 @@ public class MySteps {
        Assert.assertNotEquals(200, response.statusCode());
        Assert.assertNotEquals(200, response.statusCode());
        Assert.assertEquals(arg0, error);
        Assert.assertEquals(arg0, error);
    }
    }

    @When("the customer requests a list of transactions")
    public void theCustomerRequestsAListOfTransactions() {
        response = client.get("report/customer/" + customer.uid);
        if (response.statusCode() == 200) {
            ObjectMapper mapper = new ObjectMapper();
            try {
                transactions = mapper.readValue(response.body(), List.class);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }
    }

    @Then("the list of transactions is empty")
    public void theListOfTransactionsIsEmpty() {
        Assert.assertEquals(0, transactions.size());
    }

    @And("the merchant requests a list of transactions")
    public void theMerchantRequestsAListOfTransactions() {
        response = client.get("report/merchant/" + customer.uid);
        if (response.statusCode() == 200) {
            ObjectMapper mapper = new ObjectMapper();
            try {
                transactions = mapper.readValue(response.body(), List.class);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }
    }

    @When("the admin requests a full report")
    public void theAdminRequestsAFullReport() {
        response = client.get("report/");
        if (response.statusCode() == 200) {
            ObjectMapper mapper = new ObjectMapper();
            try {
                transactions = mapper.readValue(response.body(), List.class);
            } catch (JsonProcessingException e) {
                e.printStackTrace();
            }
        }
    }
}
}


+22 −9
Original line number Original line Diff line number Diff line
#==========================================
#==========================================
# Author: Christian
# Author: Sebastian
# Date:   Jan 2021
# Date:   Jan 2021
#==========================================
#==========================================
Feature: Report
Feature: Report


  Scenario: Costumer requests a list of his transactions
  Scenario: Costumer requests an empty list of transactions
    Given the costumer "ID"
    Given a new customer has a bank account
    When the costumer requests a list of his transactions in the time period "01-01-20,01-04-20"
    When the customer registers with their Bank Account ID as customer
    Then the costumer gets a list of his transactions for the period
    And the costumer requests 2 tokens via id
    And the customer requests a list of transactions
    Then the list of transactions is empty


  Scenario: Merchant requests a list of his transactions
  Scenario: Customer requests an empty list of transactions with no tokens
    Given the merchant "ID"
    Given a new customer has a bank account
    When the merchant requests a list of his transactions in the time period "01-01-20,01-04-20"
    When the customer registers with their Bank Account ID as customer
    Then the merchant gets a list of his transactions for the period
    And the customer requests a list of transactions
    Then the list of transactions is empty




  Scenario: Merchant requests an empty list of transactions
    Given a new merchant has a bank account
    When the merchant registers with their Bank Account ID as merchant
    And the merchant requests a list of transactions
    Then the list of transactions is empty


  Scenario: Report all empty list
    When the admin requests a full report
    Then the list of transactions is empty
 No newline at end of file
+18 −0
Original line number Original line Diff line number Diff line
@@ -79,5 +79,23 @@
			<version>1.0.0</version>
			<version>1.0.0</version>
			<scope>compile</scope>
			<scope>compile</scope>
		</dependency>
		</dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit-platform-engine</artifactId>
            <version>6.9.1</version>
            <scope>test</scope>
        </dependency>
		<dependency>
			<groupId>io.cucumber</groupId>
			<artifactId>cucumber-java</artifactId>
			<version>6.9.1</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-api</artifactId>
			<version>5.7.0</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	</dependencies>
</project>
</project>