Search in sources :

Example 1 with PropsRepositoryFake

use of com.management.fake.PropsRepositoryFake in project Internet-Software-Architectures by zivko11.

the class PropsManagerTests method AddingNewProps_ReturnsBoolean.

@Test
public void AddingNewProps_ReturnsBoolean() throws IOException {
    // Arrange
    propsRepository = new PropsRepositoryFake();
    PropsDTO dto = new PropsDTO();
    dto.setPropsDeadline(new Date());
    dto.setPropsDesc("Spoderman props description");
    dto.setPropsName("Spoderman props");
    dto.setPropsPrice(300);
    dto.setPropsModified(new Date());
    dto.setPropsUsed(true);
    byte[] byteArray = ((DataBufferByte) ImageIO.read(new File("C:\\Users\\Nikola\\Desktop\\test.png")).getData().getDataBuffer()).getData();
    dto.setPropsImage(byteArray);
    PropsManager manager = new PropsManager(propsRepository);
    // Act and assert
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Create(dto));
    Props props = propsRepository.findOne(0);
    Assert.assertEquals(dto.getPropsId(), props.getPropsId());
    Assert.assertEquals(dto.getPropsName(), props.getPropsName());
    Assert.assertEquals(dto.getPropsPrice(), props.getPropsPrice(), 0.1);
    Assert.assertEquals(dto.getPropsDeadline(), props.getPropsDeadline());
    Assert.assertEquals(dto.getPropsModified(), props.getPropsModified());
    Assert.assertEquals(dto.getPropsDesc(), props.getPropsDesc());
    Assert.assertArrayEquals(dto.getPropsImage(), props.getPropsImage());
    Assert.assertEquals(dto.isPropsUsed(), props.isPropsUsed());
}
Also used : PropsDTO(com.management.dto.PropsDTO) PropsRepositoryFake(com.management.fake.PropsRepositoryFake) DataBufferByte(java.awt.image.DataBufferByte) Props(com.management.entities.Props) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 2 with PropsRepositoryFake

use of com.management.fake.PropsRepositoryFake in project Internet-Software-Architectures by zivko11.

the class PropsControllerTests method AddingNewProps_ReturnsOK.

@Test
public void AddingNewProps_ReturnsOK() throws IOException {
    // Arrange
    Mockery mock = new Mockery();
    propsRepository = new PropsRepositoryFake();
    PropsDTO dto = new PropsDTO();
    dto.setPropsDeadline(new Date());
    dto.setPropsDesc("Spoderman hat");
    dto.setPropsName("Spoderman");
    dto.setPropsPrice(300);
    dto.setPropsModified(new Date());
    dto.setPropsUsed(true);
    byte[] byteArray = ((DataBufferByte) ImageIO.read(new File("C:\\Users\\Nikola\\Desktop\\test.png")).getData().getDataBuffer()).getData();
    dto.setPropsImage(byteArray);
    PropsManager manager = new PropsManager(propsRepository);
    PropsController controller = new PropsController(manager);
    // Act and assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.addProps(dto), new ResponseEntity<PropsDTO>(dto, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : PropsManager(com.management.managers.PropsManager) PropsDTO(com.management.dto.PropsDTO) PropsRepositoryFake(com.management.fake.PropsRepositoryFake) DataBufferByte(java.awt.image.DataBufferByte) Mockery(org.jmock.Mockery) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PropsDTO (com.management.dto.PropsDTO)2 PropsRepositoryFake (com.management.fake.PropsRepositoryFake)2 DataBufferByte (java.awt.image.DataBufferByte)2 File (java.io.File)2 Date (java.util.Date)2 Test (org.junit.Test)2 Props (com.management.entities.Props)1 PropsManager (com.management.managers.PropsManager)1 Mockery (org.jmock.Mockery)1