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

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

@@ -0,0 +1,37 @@
1
+package com.example.demo;
2
+
3
+import org.springframework.beans.factory.annotation.Autowired;
4
+import org.springframework.stereotype.Component;
5
+
6
+import javax.annotation.PostConstruct;
7
+
8
+@Component
9
+public class Alumni {
10
+
11
+    private Instructors instructors;
12
+    private Students previousCohort;
13
+
14
+    public Alumni(@Autowired Instructors instructors, @Autowired Students previousStudents) {
15
+        this.instructors = instructors;
16
+        this.previousCohort = previousStudents;
17
+    }
18
+
19
+    @PostConstruct
20
+    public void executeBootCamp() {
21
+        int hoursPerInstructors = 1200 / instructors.size();
22
+        for (Instructor i : instructors) {
23
+            i.lecture(previousCohort, hoursPerInstructors);
24
+        }
25
+    }
26
+
27
+    public Instructors getInstructor() {
28
+        return instructors;
29
+    }
30
+
31
+
32
+    public Students getPreviousCohort() {
33
+        return previousCohort;
34
+    }
35
+
36
+
37
+}

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

@@ -7,11 +7,4 @@ public class Instructors extends People<Instructor> {
7 7
     public Instructors(Instructor ... instructors) {
8 8
         super(instructors);
9 9
     }
10
-
11
-
12
-
13
-    @Override
14
-    public Iterator<Instructor> iterator() {
15
-        return null;
16
-    }
17 10
 }

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

@@ -10,14 +10,16 @@ public class InstructorsConfig {
10 10
 
11 11
     @Bean(name = "tcUsaInstructors")
12 12
     public Instructors tcUsaInstructors() {
13
-        return new Instructors();
13
+        return new Instructors(
14
+                new Instructor(1,"Leon")
15
+        );
14 16
     }
15 17
 
16 18
 
17
-    @Bean(name = "tcUkInsructors")
19
+    @Bean(name = "tcUkInstructors")
18 20
     public Instructors tcUkInstrructors (){
19 21
 
20
-        return new Instructors();
22
+        return new Instructors(new Instructor (1,"Harry"));
21 23
     }
22 24
 
23 25
 
@@ -26,6 +28,6 @@ public class InstructorsConfig {
26 28
     @Primary
27 29
     public Instructors ZipCodeInstructors(){
28 30
 
29
-        return new Instructors();
31
+        return new Instructors(new Instructor(1,"Dolio"));
30 32
     }
31 33
 }

+ 5
- 1
demo/src/main/java/com/example/demo/People.java Целия файл

@@ -2,6 +2,7 @@ package com.example.demo;
2 2
 
3 3
 import java.util.ArrayList;
4 4
 import java.util.Arrays;
5
+import java.util.Iterator;
5 6
 import java.util.List;
6 7
 
7 8
 public abstract class People <PersonType extends Person> implements Iterable<PersonType>{
@@ -49,5 +50,8 @@ public abstract class People <PersonType extends Person> implements Iterable<Per
49 50
     }
50 51
 
51 52
 
52
-
53
+    @Override
54
+    public Iterator<PersonType> iterator() {
55
+        return personList.iterator();
56
+    }
53 57
 }

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

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

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

@@ -0,0 +1,58 @@
1
+package com.example.demo;
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
13
+public class InstructorConfTest {
14
+
15
+    Instructors usaInstructors;
16
+    Instructors ukInstructors;
17
+    Instructors instructors;
18
+
19
+    @Autowired
20
+    InstructorsConfig instructorsConfig;
21
+
22
+@Before
23
+public void setup(){
24
+    usaInstructors = instructorsConfig.tcUsaInstructors();
25
+    ukInstructors = instructorsConfig.tcUkInstrructors();
26
+    instructors = instructorsConfig.ZipCodeInstructors();
27
+}
28
+
29
+   @Test
30
+    public void usaInstructorsTest(){
31
+       Assert.assertEquals(usaInstructors, instructorsConfig.tcUsaInstructors());
32
+   }
33
+   @Test
34
+   public void usaInstructorsTest1(){
35
+       Assert.assertNotNull(instructorsConfig.tcUsaInstructors());
36
+   }
37
+
38
+
39
+    @Test
40
+    public void ukInstructorsTest(){
41
+        Assert.assertEquals(ukInstructors, instructorsConfig.tcUkInstrructors());
42
+    } @Test
43
+    public void uKInstructorsTest1(){
44
+        Assert.assertNotNull(instructorsConfig.tcUkInstrructors());
45
+    }
46
+
47
+
48
+    @Test
49
+    public void instructorsTest(){
50
+        Assert.assertEquals(instructors, instructorsConfig.ZipCodeInstructors());
51
+    }
52
+
53
+    @Test
54
+    public void instructorsTest1(){
55
+        Assert.assertNotNull(instructorsConfig.ZipCodeInstructors());
56
+    }
57
+
58
+}

+ 21
- 3
demo/src/test/java/com/example/demo/StudentConfTest.java Целия файл

@@ -1,16 +1,34 @@
1 1
 package com.example.demo;
2 2
 
3
+import org.junit.Test;
3 4
 import org.junit.runner.RunWith;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.beans.factory.annotation.Qualifier;
4 7
 import org.springframework.boot.test.context.SpringBootTest;
5 8
 import org.springframework.test.context.junit4.SpringRunner;
9
+import org.springframework.util.Assert;
6 10
 
7 11
 @RunWith(SpringRunner.class)
8 12
 @SpringBootTest
9 13
 public class StudentConfTest {
10
-    Student Student;
11
-    Student prevStudent;
12 14
 
13
-    
15
+    @Autowired
16
+    @Qualifier("students")
17
+    Students students;
18
+    @Autowired
19
+    @Qualifier("previousStudents")
20
+    Students prevStudents;
21
+
22
+    @Test
23
+    public void currrentStudentTest1() {
24
+        Assert.notNull(students);
25
+    }
26
+
27
+
28
+    @Test
29
+    public void previousStudentsTest1(){
30
+        Assert.notNull(prevStudents);
31
+    }
14 32
 
15 33
 
16 34
 }