Package com.wesabe.api.accounts.params.tests

Source Code of com.wesabe.api.accounts.params.tests.CurrencyParamTest

package com.wesabe.api.accounts.params.tests;

import static com.wesabe.api.tests.util.CurrencyHelper.*;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import javax.ws.rs.WebApplicationException;

import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;

import com.wesabe.api.accounts.params.CurrencyParam;

@RunWith(Enclosed.class)
public class CurrencyParamTest {
  public static class Parsing_A_Valid_Currency_Code {
    private CurrencyParam param;
   
    @Before
    public void setup() throws Exception {
      this.param = new CurrencyParam("USD");
    }
   
    @Test
    public void itHasAValue() throws Exception {
      assertThat(param.getValue(), is(USD));
    }
  }
 
  public static class Parsing_An_Invalid_Currency_Code {
    @Test
    public void itThrowsABadRequestError() throws Exception {
      try {
        new CurrencyParam("USFD");
      } catch (WebApplicationException e) {
        assertThat((String) e.getResponse().getEntity(), is("Invalid parameter: USFD (Unknown currency code: USFD)."));
      }
    }
  }
}
TOP

Related Classes of com.wesabe.api.accounts.params.tests.CurrencyParamTest

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.