From 819d09ba3132205515a4167ae1a5bc87ea06fcd6 Mon Sep 17 00:00:00 2001
From: Ahmad Arslan <arslan0157@gmail.com>
Date: Thu, 26 May 2022 15:17:30 +0200
Subject: [PATCH] Adding Deon's repo to master manually

---
 src/main/docker/sonar/docker-compose.yml      |   4 +-
 .../sqa/{sqa => }/DemoIntegrationTest.java    |  10 +-
 .../de/rwth/swc/sqa/sqa/CustomerTest.java     | 142 ------------------
 .../java/de/rwth/swc/sqa/sqa/TicketTest.java  | 126 ----------------
 4 files changed, 6 insertions(+), 276 deletions(-)
 rename src/test/java/de/rwth/swc/sqa/{sqa => }/DemoIntegrationTest.java (80%)
 delete mode 100644 src/test/java/de/rwth/swc/sqa/sqa/CustomerTest.java
 delete mode 100644 src/test/java/de/rwth/swc/sqa/sqa/TicketTest.java

diff --git a/src/main/docker/sonar/docker-compose.yml b/src/main/docker/sonar/docker-compose.yml
index f3a5892..ae41491 100644
--- a/src/main/docker/sonar/docker-compose.yml
+++ b/src/main/docker/sonar/docker-compose.yml
@@ -2,11 +2,9 @@ version: "3"
 services:
   sonarqube:
     image: sonarqube:community
-    platform: linux/amd64
     depends_on:
       - db
     environment:
-    
       SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
       SONAR_JDBC_USERNAME: sonar
       SONAR_JDBC_PASSWORD: sonar
@@ -30,4 +28,4 @@ volumes:
   sonarqube_extensions:
   sonarqube_logs:
   postgresql:
-  postgresql_data:
+  postgresql_data:
\ No newline at end of file
diff --git a/src/test/java/de/rwth/swc/sqa/sqa/DemoIntegrationTest.java b/src/test/java/de/rwth/swc/sqa/DemoIntegrationTest.java
similarity index 80%
rename from src/test/java/de/rwth/swc/sqa/sqa/DemoIntegrationTest.java
rename to src/test/java/de/rwth/swc/sqa/DemoIntegrationTest.java
index b715368..e93c344 100644
--- a/src/test/java/de/rwth/swc/sqa/sqa/DemoIntegrationTest.java
+++ b/src/test/java/de/rwth/swc/sqa/DemoIntegrationTest.java
@@ -1,4 +1,4 @@
-package de.rwth.swc.sqa.sqa;
+package de.rwth.swc.sqa;
 
 import io.restassured.RestAssured;
 import org.junit.jupiter.api.BeforeEach;
@@ -20,8 +20,8 @@ public class DemoIntegrationTest {
         RestAssured.port = port;
     }
 
-    @Test
-    public void whenReadAll_thenStatusIsNotImplemented() {
-        given().get(PATH).then().statusCode(501);
-    }
+//    @Test
+//    public void whenReadAll_thenStatusIsNotImplemented() {
+//        given().get(PATH).then().statusCode(501);
+//    }
 }
\ No newline at end of file
diff --git a/src/test/java/de/rwth/swc/sqa/sqa/CustomerTest.java b/src/test/java/de/rwth/swc/sqa/sqa/CustomerTest.java
deleted file mode 100644
index 88ce728..0000000
--- a/src/test/java/de/rwth/swc/sqa/sqa/CustomerTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-package de.rwth.swc.sqa.sqa;
-
-
-import de.rwth.swc.sqa.model.DiscountCard;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.*;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.server.LocalServerPort;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-
-@SpringBootTest(webEnvironment = RANDOM_PORT)
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class CustomerTest {
-
-    @LocalServerPort
-    int serverPort;
-
-    @BeforeEach
-    public void setup() {
-        RestAssured.port = serverPort;
-    }
-
-
-    @Test
-    @Order(1)
-    public void addCustomerTest() {
-    	 //400
-        Map<String, Object> parms1 = new HashMap<String, Object>();
-        parms1.put("birthdate", "");
-        parms1.put("disabled", true);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms1).when().post("/customers").then().statusCode(400);
-        
-    	//200
-        Map<String, Object> parms = new HashMap<String, Object>();
-    	parms.put("birthdate", "2000-01-01");
-    	parms.put("disabled", false);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post("/customers").then().statusCode(201);
-        
-        Map<String, Object> parms3 = new HashMap<String, Object>();
-    	parms3.put("birthdate", "2001-01-01");
-    	parms3.put("disabled", false);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post("/customers").then().statusCode(201);
-       
-
-    }
-
-    @Test
-    @Order(2)
-    public void addDiscountCardToCustomerTest() {
-    	Long customerId =0L;
-    	String path = "/customers/"+customerId+"/discountcards";
-    	Map<String, Object> parms = new HashMap<String, Object>();
-        //404
-    	 customerId = 1L;
-    	path = "/customers/"+customerId+"/discountcards";
-    	parms.clear();
-    	parms.put("customerId", customerId);
-    	parms.put("id", 1L);
-    	parms.put("type", 1);
-    	parms.put("validFrom", "2022-01-01");
-    	parms.put("validFor", DiscountCard.ValidForEnum._30D);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(404);
-    	
-    	//400
-        customerId = DataService.customerList.get(0).getId();
-        path = "/customers/"+customerId+"/discountcards";
-        parms.clear();
-    	parms.put("customerId", customerId);
-    	parms.put("type", 1);
-    	parms.put("validFrom", "2022-01-01");
-    	parms.put("validFor", DiscountCard.ValidForEnum._30D);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(400);
-        
-        
-      //201
-    	customerId = DataService.customerList.get(0).getId();
-    	path = "/customers/"+customerId+"/discountcards";
-    	parms.clear();
-    	parms.put("customerId", customerId);
-    	parms.put("id", 1L);
-    	parms.put("type", 1);
-    	parms.put("validFrom", "2022-01-01");
-    	parms.put("validFor", DiscountCard.ValidForEnum._30D);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(201);
-        
-        //409 repeat conflict
-        customerId = DataService.customerList.get(0).getId();
-        path = "/customers/"+customerId+"/discountcards";
-    	parms.clear();
-    	parms.put("customerId", customerId);
-    	parms.put("id", 1L);
-    	parms.put("type", 1);
-    	parms.put("validFrom", "2022-01-01");
-    	parms.put("validFor", DiscountCard.ValidForEnum._30D);
-
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(409);
-
-
-    }
-
-    @Test
-    @Order(3)
-    public void getCustomerDiscountCardTest() {
-    	Long customerId =0L;
-    	String path = "/customers/"+customerId+"/discountcards";
-        //400
-    	path = "/customers/"+customerId+"/discountcards";
-        RestAssured.given().when().get(path).then().statusCode(400);
-    	
-    	//404
-        customerId = 11111L;
-        path = "/customers/"+customerId+"/discountcards";
-        RestAssured.given().when().get(path).then().statusCode(404);
-
-        
-        
-      //201
-    	customerId = DataService.customerList.get(0).getId();
-    	path = "/customers/"+customerId+"/discountcards";
-        RestAssured.given().when().get(path).then().statusCode(200);
-
-
-
-    }
-}
-
-
-
-
-
-
diff --git a/src/test/java/de/rwth/swc/sqa/sqa/TicketTest.java b/src/test/java/de/rwth/swc/sqa/sqa/TicketTest.java
deleted file mode 100644
index a18f808..0000000
--- a/src/test/java/de/rwth/swc/sqa/sqa/TicketTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package de.rwth.swc.sqa.sqa;
-
-
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.*;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.web.server.LocalServerPort;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
-
-@SpringBootTest(webEnvironment = RANDOM_PORT)
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class TicketTest {
-
-    @LocalServerPort
-    int serverPort;
-
-    @BeforeEach
-    public void setup() {
-        RestAssured.port = serverPort;
-    }
-
-
-    @Test
-    @Order(1)
-    public void buyTicketTest() {
-    	 //400//no birthdate
-        Map<String, Object> parms1 = new HashMap<String, Object>();
-        parms1.put("validFor", "1h");//
-        parms1.put("zone", "A");
-        parms1.put("student", true);
-        parms1.put("discountCard", true);
-        parms1.put("disabled", true);
-        parms1.put("validFrom", "2022-05-20 10:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms1).when().post("/tickets").then().statusCode(400);
-        
-    	//200
-        parms1.clear();
-        parms1.put("birthdate", "1992-01-01");
-        parms1.put("validFor", "1d");
-        parms1.put("zone", "A");
-        parms1.put("student", true);
-        parms1.put("discountCard", true);
-        parms1.put("disabled", true);
-        parms1.put("validFrom", "2022-05-20 10:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms1).when().post("/tickets").then().statusCode(200);
-        
-        parms1.clear();
-        parms1.put("birthdate", "1992-01-01");
-        parms1.put("validFor", "30d");
-        parms1.put("zone", "A");
-        parms1.put("student", true);
-        parms1.put("discountCard", true);
-        parms1.put("disabled", true);
-        parms1.put("validFrom", "2022-05-20 10:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms1).when().post("/tickets").then().statusCode(200);
-        
-       
-
-    }
-
-    @Test
-    @Order(2)
-    public void validateTicketTest() {
-    	String path = "/tickets/validate";
-    	Long ticketId =0L;
-    	Map<String, Object> parms = new HashMap<String, Object>();
-        //400 //格式不对,缺少必要信息
-    	parms.clear();
-    	parms.put("ticketId", ticketId);
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(400);
-    	
-      //403 //ticketid不对
-    	parms.clear();
-    	parms.put("ticketId", ticketId);
-    	parms.put("birthdate", "1992-01-01");
-    	parms.put("zone", "A");
-    	parms.put("student", true);
-    	parms.put("disabled", true);
-    	parms.put("date", "2022-05-22 10:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(403);
-        
-    	//403//时间过期
-        ticketId = DataService.ticketList.get(1).getId();
-        parms.clear();
-    	parms.put("ticketId", ticketId);
-    	parms.put("birthdate", "1992-01-01");
-    	parms.put("zone", "A");
-    	parms.put("student", true);
-    	parms.put("disabled", true);
-    	parms.put("date", "2022-05-22 10:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(403);
-        
-        
-      //200//信息一致,且有效期内
-        ticketId = DataService.ticketList.get(1).getId();
-        parms.clear();
-    	parms.put("ticketId", ticketId);
-    	parms.put("birthdate", "1992-01-01");
-    	parms.put("zone", "A");
-    	parms.put("student", true);
-    	parms.put("disabled", true);
-    	parms.put("date", "2022-05-20 12:00:00");
-        RestAssured.given().header("content-Type", "application/json").and()
-        .body(parms).when().post(path).then().statusCode(200);
-        
-
-
-    }
-
-}
-
-
-
-
-
-
-- 
GitLab