Skip to content

Commit

Permalink
Solved conficts with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Michedev committed Nov 24, 2016
2 parents 9664638 + d27934d commit 0ae6416
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ sudo: false

language: java

services:
- docker

cache:
directories:
- $HOME/.m2

install: true
install:
- docker pull mongo

script:
- mvn -f com.examples.exercise/pom.xml clean verify coveralls:report
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public interface Database {

public void add(Student student);

public Student takeStudentsById(String id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ public boolean addToDB(Student student) {
return true;
}

public Student getStudentById(String id) {
return database.takeStudentsById(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ public void testGetAllStudentsWhenThereIsOneStudent() {
students.add(new Student());
List<Student> allStudents = schoolController.getAllStudents();
verify(database, times(1)).getAllStudentsList();
assertEquals(1, allStudents.size());
assertEquals(1, allStudents.size());
}

@Test
public void testGetStudentByIdIterationWithDB() {
schoolController.getStudentById("0000");
verify(database, times(1)).takeStudentsById("0000");
}

@Test
public void testGetStudentByIdWithBadIndex() {
when(database.takeStudentsById("0000")).thenReturn(null);
schoolController.getAllStudents();
}

@Test
Expand All @@ -54,13 +66,21 @@ public void testAddStudentWhenIsDuplicate(){
verify(database, times(1)).exists(student.getId());

}


@Test
public void testGetStudentByIdWithCorrectedIndex() {
Student student = factoryStudent("0000", "matteo");
when(database.takeStudentsById("0000")).thenReturn(student);

Student result = schoolController.getStudentById("0000");
assertSame(student, result);
}

private Student factoryStudent(String id, String name) {
Student student = new Student();
student.setId(id);
student.setName(name);
return student;
}

}

0 comments on commit 0ae6416

Please sign in to comment.