Examples of Amount


Examples of com.manning.siia.kitchen.domain.Amount

  @Test
  public void shouldSplitRecipe() {
    Recipe recipe = RecipeObjectMother.friedEggRecipe();
    recipes.send(MessageBuilder.withPayload(recipe).build());
    receiveAndCheckIngredientMessage(new Grocery("egg", new Amount(1, Amount.Unit.PIECES)));
    receiveAndCheckIngredientMessage(new Grocery("butter", new Amount(20, Amount.Unit.GRAMS)));
  }
View Full Code Here

Examples of com.manning.siia.kitchen.domain.Amount

*/
public class RecipeObjectMother {

  public static Recipe friedEggRecipe() {
    Recipe recipe = new Recipe("fried egg");
    recipe.addIngredient(new Ingredient("egg", new Amount(1, Amount.Unit.PIECES), Ingredient.Type.Grocery));
    recipe.addIngredient(new Ingredient("butter", new Amount(20, Amount.Unit.GRAMS), Ingredient.Type.Grocery));
    return recipe;
  }
View Full Code Here

Examples of com.manning.siia.kitchen.domain.Amount

    return recipe;
  }

  public static Recipe steak() {
    Recipe recipe = new Recipe("steak");
    recipe.addIngredient(new Ingredient("steak", new Amount(1, Amount.Unit.PIECES), Ingredient.Type.Meat));
    recipe.addIngredient(new Ingredient("pepper", new Amount(2, Amount.Unit.GRAMS), Ingredient.Type.Grocery));
    recipe.addIngredient(new Ingredient("salt", new Amount(2, Amount.Unit.GRAMS), Ingredient.Type.Grocery));
    return recipe;
  }
View Full Code Here

Examples of com.manning.siia.kitchen.domain.Amount

/**
* @author Iwein Fuld
*/
public class AmountConverter implements Converter {
  public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
    Amount amount = (Amount) source;
    StringBuilder builder = new StringBuilder();
    builder.append(amount.getAmount());
    if (amount.getUnit() == Unit.GRAMS) {
      builder.append(" gr");
    }
    writer.setValue(builder.toString());
  }
View Full Code Here

Examples of com.manning.siia.kitchen.domain.Amount

  public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    final String value = reader.getValue();
    final String[] strings = value.split(" ");
    if (strings.length == 1) {
      return new Amount(Integer.parseInt(strings[0]), Unit.PIECES);
    } else if (strings[1].trim().equalsIgnoreCase("gr")) {
      return new Amount(Integer.parseInt(strings[0]), Unit.GRAMS);
    } else {
      throw new IllegalArgumentException("Could not parse Amount: " + value);
    }
  }
View Full Code Here

Examples of org.internna.iwebmvc.model.Amount

    public void testAccept() {
        assertFalse(amountParser.accept(null, null));
        assertFalse(amountParser.accept(Currency.class, null));
        assertFalse(amountParser.accept(null, new Object()));
        assertTrue(amountParser.accept(Amount.class, null));
        assertTrue(amountParser.accept(null, new Amount()));
    }
View Full Code Here

Examples of org.internna.iwebmvc.model.Amount

    }

    @Test
    public void testParse() {
        assertNull(amountParser.parse(null));
        Amount amount = new Amount();
        assertEquals(amountParser.parse(amount), amount);
        amount.setCurrency(new Currency());
        amount.getCurrency().setId(new UUID("000000aa000000aa000000aa000000aa"));
        assertEquals(amountParser.parse(amount), amount);
        Amount amount2 = new Amount();
        amount2.setCurrency(new Currency());
        amount2.getCurrency().setCurrency(java.util.Currency.getInstance("USD"));
        assertNotNull(amountParser.parse(amount2).getCurrency().getId());
    }
View Full Code Here

Examples of org.internna.iwebmvc.model.Amount

            Currency eur = Currency.obtain("EUR", dao), usd = Currency.obtain("USD", dao);
            int count = 0;
            for (int i = 0; i < (30 + Math.round(Math.random() * 20)); i++) {
              emitted = !emitted;
                Order o = new Order();
                o.setAmount(new Amount());
                double aux = Math.random();
                try {
                    o.setIdentifier(new I18nText());
                    for (Locale l : supportedLocales) o.getIdentifier().add(l, l + ":" + StringUtils.SHA1(String.valueOf(aux)));
              } catch (Exception e) {};
View Full Code Here

Examples of org.jscience.physics.amount.Amount

        return retval;
    }
    public static ComplexAmount valueOf(String s){
        /* Amount is positive, Complex is unit vector */
        ComplexAmount retval=new ComplexAmount();
        Amount amount = Amount.valueOf(s);
        retval.cUnit = amount.getUnit();
        retval.cComplex=Complex.valueOf(amount.doubleValue(amount.getUnit()),0);

        return retval;
    }
View Full Code Here

Examples of org.thymeleaf.itutorial.beans.Amount

        return customers;
    }

    public static Amount loadAmount() {
        BigDecimal amount = new BigDecimal("2599.50");
        return new Amount(amount);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.