Package com.wesabe.api.accounts.presenters.tests

Source Code of com.wesabe.api.accounts.presenters.tests.MerchantReferencePresenterTest

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

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

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

import com.wesabe.api.accounts.entities.Merchant;
import com.wesabe.api.accounts.presenters.MerchantReferencePresenter;
import com.wesabe.xmlson.XmlsonObject;

@RunWith(Enclosed.class)
public class MerchantReferencePresenterTest {
  public static class Presenting_A_Merchant {
    private Merchant merchant;
    private MerchantReferencePresenter presenter;
   
    @Before
    public void setup() throws Exception {
      this.merchant = mock(Merchant.class);
      when(merchant.getName()).thenReturn("Starbucks");
      when(merchant.getId()).thenReturn(20);
     
      this.presenter = new MerchantReferencePresenter();
    }
   
    @Test
    public void itIsNamedMerchant() throws Exception {
      final XmlsonObject representation = presenter.present(merchant);
     
      assertThat(representation.getName(), is("merchant"));
    }
   
    @Test
    public void itHasAName() throws Exception {
      final XmlsonObject representation = presenter.present(merchant);
     
      assertThat(representation.getString("name"), is("Starbucks"));
    }
   
    @Test
    public void itHasAnId() throws Exception {
      final XmlsonObject representation = presenter.present(merchant);
     
      assertThat(representation.getInteger("id"), is(20));
    }
   
    @Test
    public void itHasAUri() throws Exception {
      final XmlsonObject representation = presenter.present(merchant);
     
      assertThat(representation.getString("uri"), is("/transactions/merchant/20"));
    }
  }
}
TOP

Related Classes of com.wesabe.api.accounts.presenters.tests.MerchantReferencePresenterTest

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.
[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-20639858-1', 'auto'); ga('send', 'pageview');