소스 검색

add some test files. add some annotations.

171870002 5 년 전
부모
커밋
4b434be92f
20개의 변경된 파일232개의 추가작업 그리고 22개의 파일을 삭제
  1. 0 7
      src/main/java/com/example/data_structure/controller/GranphController.java
  2. 16 0
      src/main/java/com/example/data_structure/controller/GraphController.java
  3. 11 1
      src/main/java/com/example/data_structure/controller/HanoiController.java
  4. 0 12
      src/main/java/com/example/data_structure/controller/HelloController.java
  5. 9 1
      src/main/java/com/example/data_structure/controller/StackController.java
  6. 15 0
      src/main/java/com/example/data_structure/domain/Graph.java
  7. 12 0
      src/main/java/com/example/data_structure/domain/Hanoi.java
  8. 13 0
      src/main/java/com/example/data_structure/domain/Sorting.java
  9. 16 0
      src/main/java/com/example/data_structure/domain/Stack.java
  10. 1 0
      src/main/java/com/example/data_structure/vo/Bar.java
  11. 7 0
      src/main/java/com/example/data_structure/vo/InsertionSortVO.java
  12. 7 0
      src/main/java/com/example/data_structure/vo/QuickSortVO.java
  13. 7 0
      src/main/java/com/example/data_structure/vo/SelectionSortVO.java
  14. 52 1
      src/main/java/com/example/data_structure/vo/StackVO.java
  15. 11 0
      src/test/java/com/example/data_structure/controller/GraphControllerTest.java
  16. 11 0
      src/test/java/com/example/data_structure/controller/HanoiControllerTest.java
  17. 11 0
      src/test/java/com/example/data_structure/controller/StackControllerTest.java
  18. 11 0
      src/test/java/com/example/data_structure/service/GraphServiceTest.java
  19. 11 0
      src/test/java/com/example/data_structure/service/HanoiServiceTest.java
  20. 11 0
      src/test/java/com/example/data_structure/service/StackServiceTest.java

+ 0 - 7
src/main/java/com/example/data_structure/controller/GranphController.java

@@ -1,7 +0,0 @@
-package com.example.data_structure.controller;
-
-import org.springframework.stereotype.Controller;
-
-@Controller
-public class GranphController {
-}

+ 16 - 0
src/main/java/com/example/data_structure/controller/GraphController.java

@@ -0,0 +1,16 @@
+package com.example.data_structure.controller;
+
+import com.example.data_structure.service.GraphService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@CrossOrigin
+public class GraphController {
+
+    @Autowired
+    GraphService graphService;
+}

+ 11 - 1
src/main/java/com/example/data_structure/controller/HanoiController.java

@@ -1,9 +1,19 @@
 package com.example.data_structure.controller;
 
 
+import com.example.data_structure.domain.Hanoi;
+import com.example.data_structure.service.HanoiService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
 
-@Controller
+@RestController
+@CrossOrigin
 public class HanoiController {
+
+    @Autowired
+    HanoiService hanoiService;
 }

+ 0 - 12
src/main/java/com/example/data_structure/controller/HelloController.java

@@ -1,12 +0,0 @@
-package com.example.data_structure.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-
-@Controller
-public class HelloController {
-    @RequestMapping("/index")
-    public String sayHello(){
-        return "index";
-    }
-}

+ 9 - 1
src/main/java/com/example/data_structure/controller/StackController.java

@@ -1,8 +1,16 @@
 package com.example.data_structure.controller;
 
 
+import com.example.data_structure.service.StackService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RestController;
 
-@Controller
+@RestController
+@CrossOrigin
 public class StackController {
+
+    @Autowired
+    StackService stackService;
 }

+ 15 - 0
src/main/java/com/example/data_structure/domain/Graph.java

@@ -141,4 +141,19 @@ public class Graph {
     public void setWeight(ArrayList<ArrayList<Double>> weight) {
         this.weight = weight;
     }
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "Graph{" +
+                "isDirected=" + isDirected +
+                ", isWeighted=" + isWeighted +
+                ", nodeNum=" + nodeNum +
+                ", edgeNum=" + edgeNum +
+                ", nodeList=" + nodeList +
+                ", graph=" + graph +
+                ", weight=" + weight +
+                '}';
+    }
 }

+ 12 - 0
src/main/java/com/example/data_structure/domain/Hanoi.java

@@ -62,4 +62,16 @@ public class Hanoi {
     public void setC(String c) {
         this.c = c;
     }
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "Hanoi{" +
+                "n=" + n +
+                ", a='" + a + '\'' +
+                ", b='" + b + '\'' +
+                ", c='" + c + '\'' +
+                '}';
+    }
 }

+ 13 - 0
src/main/java/com/example/data_structure/domain/Sorting.java

@@ -110,4 +110,17 @@ public class Sorting {
     public void setDesc(boolean desc) {
         isDesc = desc;
     }
+
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "Sorting{" +
+                "size=" + size +
+                ", elementType='" + elementType + '\'' +
+                ", content=" + content +
+                ", isDesc=" + isDesc +
+                '}';
+    }
 }

+ 16 - 0
src/main/java/com/example/data_structure/domain/Stack.java

@@ -23,6 +23,7 @@ public class Stack {
         this.capacity = capacity;
         this.elementType = elementType;
         this.content = content;
+        this.size=content.size();
     }
 
     /**
@@ -33,6 +34,8 @@ public class Stack {
     public Stack( String elementType, ArrayList<Object> content) {
         this.elementType = elementType;
         this.content = content;
+        this.capacity=MAX_SIZE;
+        this.size=content.size();
     }
 
     public Stack() {
@@ -105,4 +108,17 @@ public class Stack {
     public void setContent(ArrayList<Object> content) {
         this.content = content;
     }
+
+
+    //toString
+
+    @Override
+    public String toString() {
+        return "Stack{" +
+                "capacity=" + capacity +
+                ", size=" + size +
+                ", elementType='" + elementType + '\'' +
+                ", content=" + content +
+                '}';
+    }
 }

+ 1 - 0
src/main/java/com/example/data_structure/vo/Bar.java

@@ -49,4 +49,5 @@ public class Bar {
         Bar copyBar=new Bar(bar.getValue(),bar.getColor());
         return copyBar;
     }
+
 }

+ 7 - 0
src/main/java/com/example/data_structure/vo/InsertionSortVO.java

@@ -0,0 +1,7 @@
+package com.example.data_structure.vo;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class InsertionSortVO {
+}

+ 7 - 0
src/main/java/com/example/data_structure/vo/QuickSortVO.java

@@ -0,0 +1,7 @@
+package com.example.data_structure.vo;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class QuickSortVO {
+}

+ 7 - 0
src/main/java/com/example/data_structure/vo/SelectionSortVO.java

@@ -0,0 +1,7 @@
+package com.example.data_structure.vo;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class SelectionSortVO {
+}

+ 52 - 1
src/main/java/com/example/data_structure/vo/StackVO.java

@@ -2,7 +2,58 @@ package com.example.data_structure.vo;
 
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
+
 @Component
 public class StackVO {
-    private int id;
+    private int capacity;
+    private int size;
+    private ArrayList<Integer> content;
+
+    public StackVO(int capacity,ArrayList<Integer> content){
+        this.capacity=capacity;
+        this.content=content;
+        this.size=content.size();
+    }
+
+    public StackVO() {
+    }
+
+
+    //getter
+
+    public int getCapacity() {
+        return capacity;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public ArrayList<Integer> getContent() {
+        return content;
+    }
+
+    //setter
+    public void setCapacity(int capacity) {
+        this.capacity = capacity;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public void setContent(ArrayList<Integer> content) {
+        this.content = content;
+    }
+
+    //toString
+    @Override
+    public String toString() {
+        return "StackVO{" +
+                "capacity=" + capacity +
+                ", size=" + size +
+                ", content=" + content +
+                '}';
+    }
 }

+ 11 - 0
src/test/java/com/example/data_structure/controller/GraphControllerTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class GraphControllerTest {
+
+    @Autowired
+    GraphController graphController;
+}

+ 11 - 0
src/test/java/com/example/data_structure/controller/HanoiControllerTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class HanoiControllerTest {
+
+    @Autowired
+    HanoiController hanoiController;
+}

+ 11 - 0
src/test/java/com/example/data_structure/controller/StackControllerTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class StackControllerTest {
+
+    @Autowired
+    StackController stackController;
+}

+ 11 - 0
src/test/java/com/example/data_structure/service/GraphServiceTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class GraphServiceTest {
+
+    @Autowired
+    GraphService graphService;
+}

+ 11 - 0
src/test/java/com/example/data_structure/service/HanoiServiceTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class HanoiServiceTest {
+
+    @Autowired
+    HanoiService hanoiService;
+}

+ 11 - 0
src/test/java/com/example/data_structure/service/StackServiceTest.java

@@ -0,0 +1,11 @@
+package com.example.data_structure.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+public class StackServiceTest {
+
+    @Autowired
+    StackService stackService;
+}