Java Code Examples for org.joda.money.Money#parse()

The following examples show how to use org.joda.money.Money#parse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmployeeRestControllerTest.java    From batchers with Apache License 2.0 6 votes vote down vote up
@Test
public void givenOneEmployee_whenGetEmployees_thenReturnCorrectJson() throws Exception {
    Employee employee = new EmployeeTestBuilder()
            .withIncome(200)
            .withFirstName("firstName")
            .build();

    EmployeeTo employeeTo = new EmployeeTo(employee.getFirstName(), employee.getLastName(), employee.getEmail(), employee.getIncome(), Money.parse("EUR 200"), 1L, 0l);
    String expectedJSON = new Jackson2JsonObjectMapper().toJson(asList(employeeTo));
    when(presentationEmployeeRepository.getEmployees(0, 10)).thenReturn(asList(employeeTo));

    MvcResult mvcResult = mockMvc.perform(get("/employees?page=0&pageSize=10").contentType(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andReturn();

    String actualJSON = mvcResult.getResponse().getContentAsString();

    assertThat(actualJSON).isEqualTo(expectedJSON);
}
 
Example 2
Source File: MoneyParameter.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private static Money parse(String value) {
  // Add space after currency code if it's missing, to make the CLI a bit friendlier.
  if (value.length() > 3 && value.charAt(3) != ' ') {
    value = String.format("%s %s", value.substring(0, 3), value.substring(3));
  }
  return Money.parse(Ascii.toUpperCase(value));
}
 
Example 3
Source File: BigDecimalColumnMoneyMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public Money fromNonNullString(String s) {
	return Money.parse(s);
}
 
Example 4
Source File: LongColumnMoneyMinorMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public Money fromNonNullString(String s) {
	return Money.parse(s);
}
 
Example 5
Source File: LongColumnMoneyMajorMapper.java    From jadira with Apache License 2.0 4 votes vote down vote up
@Override
public Money fromNonNullString(String s) {
	return Money.parse(s);
}