Nuridalia.Hernandez преди 5 години
родител
ревизия
8f64349472

+ 3
- 0
demo/src/main/java/com/example/demo/Classroom.java Целия файл

@@ -3,10 +3,13 @@ package com.example.demo;
3 3
 public class Classroom {
4 4
     private Instructors instructors;
5 5
     private Students students;
6
+
7
+
6 8
     public Classroom(){
7 9
 
8 10
     }
9 11
 
12
+
10 13
     public Classroom(Instructors instructors, Students students) {
11 14
         this.instructors = instructors;
12 15
         this.students = students;

+ 4
- 4
demo/src/main/java/com/example/demo/ClassroomConfig.java Целия файл

@@ -10,16 +10,16 @@ public class ClassroomConfig {
10 10
 
11 11
     @Bean(name = "currentCohort")
12 12
     @DependsOn({"instructors", "students"})
13
-    public Classroom currentCohort(Instructors instructors , Students students){
14
-    return new Classroom(instructors, students);
13
+    public Classroom currentCohort(){
14
+    return new Classroom(new Instructors(), new Students());
15 15
     }
16 16
 
17 17
 
18 18
 
19 19
     @Bean(name = "previousCohort")
20 20
     @DependsOn({"instructors" , "students"})
21
-    public Classroom previousCohort(Instructors instructors, Students students){
22
-        return new Classroom(instructors, students);
21
+    public Classroom previousCohort(){
22
+        return new Classroom(new Instructors(), new Students());
23 23
 
24 24
     }
25 25
 

+ 4
- 0
demo/src/test/java/com/example/demo/AlumniTest.java Целия файл

@@ -0,0 +1,4 @@
1
+package com.example.demo;
2
+
3
+public class AlumniTest {
4
+}

+ 48
- 1
demo/src/test/java/com/example/demo/ClassromConfigTest.java Целия файл

@@ -1,6 +1,53 @@
1 1
 package com.example.demo;
2 2
 
3
+import org.junit.Assert;
4
+import org.junit.Before;
5
+import org.junit.Test;
6
+import org.junit.runner.RunWith;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.boot.test.context.SpringBootTest;
9
+import org.springframework.test.context.junit4.SpringRunner;
10
+
11
+@RunWith(SpringRunner.class)
12
+@SpringBootTest
3 13
 public class ClassromConfigTest {
4 14
 
5
-    
15
+Classroom currentCohort;
16
+Classroom prevCohort;
17
+
18
+
19
+    @Autowired
20
+    ClassroomConfig classroomConfig;
21
+    @Before
22
+    public void setUp(){
23
+        currentCohort = classroomConfig.currentCohort();
24
+        prevCohort= classroomConfig.previousCohort();
25
+    }
26
+@Test
27
+    public void CurrentCohortTest(){
28
+    Assert.assertEquals(currentCohort, classroomConfig.currentCohort());
29
+}@Test
30
+    public void CurrentCohortTest1(){
31
+        Assert.assertNotEquals(currentCohort, classroomConfig.previousCohort());
32
+    }
33
+    @Test
34
+    public void CurrentCohortTest2(){
35
+        Assert.assertNotNull(classroomConfig.currentCohort());
36
+    }
37
+
38
+
39
+   @Test
40
+     public void previousCohortTest1(){
41
+        Assert.assertEquals(prevCohort, classroomConfig.previousCohort());
42
+
43
+    }
44
+    @Test
45
+    public void previousCohortTest2(){
46
+        Assert.assertNotNull(classroomConfig.previousCohort());
47
+
48
+    }
49
+
50
+
51
+
52
+
6 53
 }