This file contains 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
@RunWith(JUnitParamsRunner.class) | |
public class LoanProcessorParameterizedTest2 { | |
@Test | |
@Parameters(method = "testRequestLoan_Parameters") | |
public void testRequestLoan(float loanAmount, float downPayment, float availableFunds, | |
boolean expectApproved, String expectedMessage) throws Throwable | |
{ | |
... | |
} |
This file contains 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
@Test | |
public void testRequestLoan() throws Throwable | |
{ | |
// Given | |
LoanProcessor underTest = new LoanProcessor(); | |
// When | |
LoanResponse result = underTest.requestLoan(loanAmount, downPayment, availableFunds); | |
// Then |
This file contains 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
@Parameters(name = "Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}") | |
public static Iterable<Object[]> data() throws Throwable | |
{ | |
return Arrays.asList(new Object[][] { | |
{ 1000.0f, 200.0f, 250.0f, true, null }, | |
{ 1000.0f, 50.0f, 250.0f, false, "error.insufficient.down.payment" }, | |
{ 1000.0f, 200.0f, 150.0f, false, "error.insufficient.funds.for.down.payment" } | |
}); | |
} |
This file contains 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
@Parameters(name = "Run {index}: loanAmount={0}, downPayment={1}, availableFunds={2}, expectApproved={3}, expectedMessage={4}") | |
public static Iterable<Object[]> data() throws Throwable | |
{ | |
return Arrays.asList(new Object[][] { | |
{ 1000.0f, 200.0f, 250.0f, true, null } | |
}); | |
} |
This file contains 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
@RunWith(Parameterized.class) | |
public class LoanProcessorParameterizedTest { | |
float loanAmount; | |
float downPayment; | |
float availableFunds; | |
boolean expectApproved; | |
String expectedMessage; | |
public LoanProcessorParameterizedTest(float loanAmount, float downPayment, |
This file contains 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
@Test | |
public void testRequestLoan() throws Throwable | |
{ | |
// Given | |
LoanProcessor underTest = new LoanProcessor(); | |
// When | |
LoanResponse result = underTest.requestLoan(1000f, 200f, 250f); | |
// Then |
This file contains 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 LoanResponse requestLoan(float loanAmount, float downPayment, float availableFunds) | |
{ | |
LoanResponse response = new LoanResponse(); | |
response.setApproved(true); | |
if (availableFunds < downPayment) { | |
response.setApproved(false); | |
response.setMessage("error.insufficient.funds.for.down.payment"); | |
return response; | |
} |
NewerOlder