This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *** Settings *** | |
| Library RequestsLibrary | |
| *** Test cases *** | |
| Response From User Resource Should Be OK | |
| Create Session app http://localhost:8882 | |
| ${resp}= Get Request app /users | |
| Should Be Equal As Strings ${resp.status_code} 200 Status code should be 200 but got ${resp.status_code} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *** Settings *** | |
| Library RequestsLibrary | |
| *** Test cases *** | |
| Response From User Resource Should Be OK | |
| Create Session app http://localhost:8882 | |
| ${resp}= Get Request app /users | |
| Should Be Equal As Strings ${resp.status_code} 200 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FizzBuzzTest { | |
| @Test | |
| public void say_Given1_Return1(){ | |
| FizzBuzz fizzBuzz = new FizzBuzz(); | |
| String result = fizzBuzz.say(3); | |
| Assert.assertEquals(String.format("Should say fizz when given 3 but got %s", result), "fizz", result); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class FizzBuzzTest { | |
| @Test | |
| public void say_Given1_Return1(){ | |
| FizzBuzz fizzBuzz = new FizzBuzz(); | |
| String result = fizzBuzz.say(3); | |
| Assert.assertEquals("fizz", result); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UserIDNotFoundException extends RuntimeException { | |
| public UserIDNotFoundException(String userID){ | |
| super(String.format("User not found by id %s", userID)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UsersResource { | |
| public User findUserById(String userId){ | |
| User result = userDAO.findById(userId); | |
| if( result == null ){ | |
| throw new RuntimeException(String.format("User not found by id %s", userId)); | |
| } | |
| return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class UsersResource { | |
| public User findUserById(String userId){ | |
| User result = userDAO.findById(userId); | |
| if( result == null ){ | |
| throw new RuntimeException(); | |
| } | |
| return result; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| import java.util.LinkedHashMap; | |
| import java.util.Map; | |
| public class GradeConverter { | |
| public String fromScore(Integer score) { | |
| Map<Integer, String> rules = getConversionRules(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| public class MyGradeController { | |
| private GradeDisplay display; | |
| private GradeConverter converter = new GradeConverter(); | |
| public MyGradeController(GradeDisplay display){ | |
| this.display = display; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.example.GradeConverter; | |
| import com.example.GradeDisplay; | |
| import com.example.MyGradeController; | |
| import org.junit.Before; | |
| import org.junit.Test; | |
| import org.mockito.Mockito; | |
| public class MyGradeControllerTest { |