package pl.koszela.jan.persistence.dto;

import javax.annotation.Resource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.assertj.core.api.Assertions.*;
/**
 * Created on 10.08.2017.
 *
 * @author Jan Koszela
 */
@ActiveProfiles("test")
@RunWith(SpringJUnit4ClassRunner.class)
public class JsonProductDTOTest {

  @Resource
  private ProductDTO productDTO;

  @Before
  public void setUp() throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("mvc-dispatcher-servlet.xml");
    ProductDTO dto = (ProductDTO) context.getBean("productDTO");
    dto.setId(1);
  }

  @Test
  public void shouldGetIdFromJSON() {
    assertThat(productDTO.getId()).isEqualTo(1);
  }

  @Test
  public void testGetCompetition() {

  }
}

@@ -38,42 +38,8 @@
 o;%0A%0A
-import javax.annotation.Resource;%0A
 impo
@@ -130,125 +130,40 @@
 org.
-springframework.context.ApplicationContext;%0Aimport org.springframework.context.support.ClassPathXmlApplicationContext
+mockito.junit.MockitoJUnitRunner
 ;%0Aim
@@ -227,71 +227,61 @@
 ort 
-org.springframework.test.context.junit4.SpringJUnit4ClassRunner
+pl.koszela.jan.persistence.dto.impl.DefaultProductDTO
 ;%0A%0Ai
@@ -328,16 +328,57 @@
 ions.*;%0A
+import static org.mockito.Mockito.when;%0A%0A
 /**%0A * C
@@ -429,16 +429,17 @@
 ela%0A */%0A
+%0A
 @ActiveP
@@ -467,25 +467,20 @@
 ith(
-SpringJUnit4Class
+MockitoJUnit
 Runn
@@ -506,12 +506,15 @@
 ass 
-Json
+Default
 Prod
@@ -530,20 +530,228 @@
 t %7B%0A
-%0A  @Resource
+  public static final int ID = 1;%0A  public static final String ITEM = %22Civic%22;%0A  public static final int UNIT_PRICE = 72;%0A  public static final String CURRENCY = %22EUR%22;%0A  public static final boolean MULTIPRICING = true;%0A
 %0A  p
@@ -768,17 +768,22 @@
 ductDTO 
-p
+givenP
 roductDT
@@ -821,132 +821,475 @@
 Up()
- throws Exception %7B%0A    ApplicationContext context = new ClassPathXmlApplicationContext(%22mvc-dispatcher-servlet.xml%22
+%7B%0A    givenProductDTO = createProductDTO(ID, ITEM, UNIT_PRICE, CURRENCY, MULTIPRICING);%0A  %7D%0A%0A  private ProductDTO createProductDTO(int id, String item, int unitPrice, String currency,%0A      boolean multipricing) %7B%0A    DefaultProductDTO productDTO = new DefaultProductDTO();%0A    productDTO.setId(id);%0A    productDTO.setItem(item);%0A    productDTO.setUnitPrice(unitPrice);%0A    productDTO.setCurrency(currency);%0A    productDTO.setMultipricing(multipricing
 );%0A
+%0A
     
-P
+return p
 rodu
@@ -1297,74 +1297,329 @@
 tDTO
- dto = (ProductDTO) context.getBean(%22productDTO%22);%0A    dto.setId(1
+;%0A  %7D%0A%0A  @Test%0A  public void shouldGetId() %7B%0A    assertThat(givenProductDTO.getId()).isEqualTo(ID);%0A  %7D%0A%0A  @Test%0A  public void shouldGetItem() %7B%0A    assertThat(givenProductDTO.getItem()).isEqualTo(ITEM);%0A  %7D%0A%0A  @Test%0A  public void shouldGetUnitPrice() %7B%0A    assertThat(givenProductDTO.getUnitPrice()).isEqualTo(UNIT_PRICE
 );%0A 
@@ -1657,18 +1657,16 @@
 dGet
-IdFromJSON
+Currency
 () %7B
@@ -1681,17 +1681,22 @@
 ertThat(
-p
+givenP
 roductDT
@@ -1692,34 +1692,40 @@
 enProductDTO.get
-Id
+Currency
 ()).isEqualTo(1)
@@ -1722,17 +1722,24 @@
 EqualTo(
-1
+CURRENCY
 );%0A  %7D%0A%0A
@@ -1764,31 +1764,199 @@
 oid 
-testGetCompetition() %7B%0A
+shouldGetMultipricing() %7B%0A    assertThat(givenProductDTO.isMultipricing()).isEqualTo(MULTIPRICING);%0A  %7D%0A%0A  @Test%0A  public void shouldBeNotNull() %7B%0A    assertThat(givenProductDTO).isNotNull();
 %0A  %7D

Add sample DTO tests