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
Map<String, Object> model = MockMvcBuilders.standaloneSetup(controller).build() | |
.perform(request) | |
.andExpect(status().isOk()) | |
.andReturn().getModelAndView().getModel(); | |
assertFalse(((BeanPropertyBindingResult)model.get(ERROR_KEY)).hasErrors()); |
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
/** | |
* | |
*/ | |
package com.bmchild.validation.constraints; | |
import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | |
import static java.lang.annotation.ElementType.CONSTRUCTOR; | |
import static java.lang.annotation.ElementType.FIELD; | |
import static java.lang.annotation.ElementType.TYPE; | |
import static java.lang.annotation.ElementType.METHOD; |
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
// imports etc... | |
public class MyTest { | |
private MyClassUnderTest myClassUnderTest = new MyClassUnderTest(); | |
@Rule | |
public ExpectedException expectedException = ExpectedException.none(); | |
@Test |
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
<c:catch var="exception"> | |
<jsp:include page="/WEB-INF/jsp/doesntexist.jsp" /> | |
</c:catch> | |
<c:if test="${ exception != null }"> | |
included page not found: ${exception.message} | |
<br /> | |
Here is the stacktrace: ${exception.stackTrace} | |
</c:if> |
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
<c:forEach var="entry" items="${theMap}"> | |
Key: <c:out value="${entry.key}"/> | |
Value: <c:out value="${entry.value}"/> | |
</c:forEach> |
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
# Directories # | |
/build/ | |
/bin/ | |
target/ | |
# OS Files # | |
.DS_Store | |
*.class | |
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 Failed Validation - missing ssn param | |
DefaultRequestBuilder requestBad = post(url) | |
.param("isEmployee", "true"); | |
MockMvcBuilders.standaloneSetup(controller).build() | |
.perform(requestBad) | |
.andExpect(status().isOk()) | |
.andExpect(model().attributeHasFieldErrors("lookupBean", "ssn")); |
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
@Override | |
public BigDecimal calculatePaymentAmount(BigDecimal orignalValue, | |
BigDecimal ratePerPeriod, Integer numberOfPeriods) { | |
BigDecimal pv = orignalValue.setScale(CURRENCY_SCALE, BigDecimal.ROUND_HALF_UP); | |
BigDecimal r = ratePerPeriod.setScale(PRECISE_SCALE, BigDecimal.ROUND_HALF_UP); | |
BigDecimal denom = BigDecimal.ONE.subtract( BigDecimal.ONE.add(r).pow(-numberOfPeriods, MathContext.DECIMAL64) ); | |
BigDecimal num = r.multiply(pv); | |
return num.divide(denom, CURRENCY_SCALE, BigDecimal.ROUND_HALF_UP); | |
} |
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
@Override | |
public BigDecimal calculateApr(BigDecimal financeCharge, BigDecimal totalPrincipal, int numberOfPayments, | |
int periodsPerYear, int precision, int roundingMode) { | |
BigDecimal numOfPayments = new BigDecimal(numberOfPayments).setScale(precision); | |
BigDecimal periodsInYear = new BigDecimal(periodsPerYear).setScale(precision); | |
BigDecimal years = numOfPayments.divide(periodsInYear, roundingMode); | |
BigDecimal avg = totalPrincipal.setScale(precision, roundingMode).divide(numOfPayments, roundingMode); | |
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
-- Gets the table's info including columns, primary key, foreign keys, and more | |
exec sp_help 'MY_TABLE'; |