Package org.multibit.mbm.client.domain.model.pricing

Source Code of org.multibit.mbm.client.domain.model.pricing.PriceBuilderTest

package org.multibit.mbm.client.domain.model.pricing;

import com.xeiam.xchange.currency.MoneyUtils;
import org.joda.money.BigMoney;
import org.junit.Test;
import org.multibit.mbm.client.domain.model.model.PricingRule;
import org.multibit.mbm.client.domain.model.model.Role;
import org.multibit.mbm.client.domain.model.model.User;
import org.multibit.mbm.client.infrastructure.persistence.DatabaseLoader;

import static junit.framework.Assert.assertEquals;

public class PriceBuilderTest {

  @Test
  public void testBuild() throws Exception {

    // Configure the Supplier
    Role supplierRole = DatabaseLoader.buildSupplierRole();
    User steveUser = DatabaseLoader.buildSteveSupplier(supplierRole);

    BigMoney unitPrice = MoneyUtils.parse("GBP 1.23");

    // Configure some PricingRules
    PricingRule pricingRule = DatabaseLoader.buildPresetMarginPricingRule();

    BigMoney price = PriceBuilder
      .newInstance()
      .withSupplier(steveUser.getSupplier())
      .withPricingRule(pricingRule)
      .withStartingPrice(unitPrice)
      .build();

    assertEquals("GBP 1.476",price.toString());

  }
}
TOP

Related Classes of org.multibit.mbm.client.domain.model.pricing.PriceBuilderTest

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.