Skip to content

Commit

Permalink
BpmnBankConfig & BpmnBankConfigDTO Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisKina-dev committed Nov 7, 2023
1 parent 52cd174 commit 9d0a9ac
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package it.gov.pagopa.atmlayer.service.model.entity;

import io.quarkus.test.junit.QuarkusTest;
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.sql.Timestamp;

import static org.junit.jupiter.api.Assertions.assertEquals;

@QuarkusTest
public class BpmnBankConfigTest {

private BpmnBankConfig bpmnBankConfig;

@BeforeEach
public void setUp() {
bpmnBankConfig = new BpmnBankConfig();
}

@Test
public void testGettersAndSetters() {

BpmnBankConfigPK bpmnBankConfigPK = new BpmnBankConfigPK();
bpmnBankConfig.setBpmnBankConfigPK(bpmnBankConfigPK);
assertEquals(bpmnBankConfigPK, bpmnBankConfig.getBpmnBankConfigPK());

FunctionTypeEnum functionType = FunctionTypeEnum.MENU;
bpmnBankConfig.setFunctionType(functionType);
assertEquals(functionType, bpmnBankConfig.getFunctionType());

Timestamp createdAt = new Timestamp(System.currentTimeMillis());
bpmnBankConfig.setCreatedAt(createdAt);
assertEquals(createdAt, bpmnBankConfig.getCreatedAt());

Timestamp lastUpdatedAt = new Timestamp(System.currentTimeMillis());
bpmnBankConfig.setLastUpdatedAt(lastUpdatedAt);
assertEquals(lastUpdatedAt, bpmnBankConfig.getLastUpdatedAt());

String createdBy = "name";
bpmnBankConfig.setCreatedBy(createdBy);
assertEquals(createdBy, bpmnBankConfig.getCreatedBy());

String lastUpdatedBy = "surname";
bpmnBankConfig.setLastUpdatedBy(lastUpdatedBy);
assertEquals(lastUpdatedBy, bpmnBankConfig.getLastUpdatedBy());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package it.gov.pagopa.atmlayer.service.model.model;

import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum;
import org.junit.jupiter.api.Test;
import java.sql.Timestamp;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;


public class BpmnBankConfigDTOTest {
@Test
public void testNoArgsConstructor() {
BpmnBankConfigDTO dto = new BpmnBankConfigDTO();
assertNotNull(dto);
}

@Test
public void testAllArgsConstructor() {
BpmnBankConfigDTO dto = new BpmnBankConfigDTO(
UUID.randomUUID(), 1L, "acquirer", "branch", "terminal",
FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()),
new Timestamp(System.currentTimeMillis()), "creator", "updator");
assertNotNull(dto);
}

@Test
public void testGetterAndSetter() {
BpmnBankConfigDTO dto = new BpmnBankConfigDTO();

dto.setBpmnId(UUID.randomUUID());
assertNotEquals(dto.getBpmnId(), UUID.randomUUID());

dto.setBpmnModelVersion(1L);
assertEquals(dto.getBpmnModelVersion(), 1L);

dto.setAcquirerId("acquirer");
assertEquals(dto.getAcquirerId(), "acquirer");

dto.setBranchId("branch");
assertEquals(dto.getBranchId(), "branch");

dto.setTerminalId("terminal");
assertEquals(dto.getTerminalId(), "terminal");

dto.setFunctionType(FunctionTypeEnum.MENU);
assertEquals(dto.getFunctionType(), FunctionTypeEnum.MENU);

Timestamp createdAt = new Timestamp(System.currentTimeMillis());
dto.setCreatedAt(createdAt);
assertEquals(dto.getCreatedAt(), createdAt);

Timestamp lastUpdatedAt = new Timestamp(System.currentTimeMillis());
dto.setLastUpdatedAt(lastUpdatedAt);
assertEquals(dto.getLastUpdatedAt(), lastUpdatedAt);

dto.setCreatedBy("creator");
assertEquals(dto.getCreatedBy(), "creator");

dto.setLastUpdatedBy("updator");
assertEquals(dto.getLastUpdatedBy(), "updator");
}

@Test
public void testEqualsAndHashCode() {
BpmnBankConfigDTO dto1 = new BpmnBankConfigDTO(
UUID.randomUUID(), 1L, "acquirer", "branch", "terminal",
FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()),
new Timestamp(System.currentTimeMillis()), "creator", "updator");
BpmnBankConfigDTO dto2 = new BpmnBankConfigDTO(
UUID.randomUUID(), 1L, "acquirer", "branch", "terminal",
FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()),
new Timestamp(System.currentTimeMillis()), "creator", "updator");

assertNotEquals(dto1, dto2);
assertNotEquals(dto1.hashCode(), dto2.hashCode());
}

@Test
public void testToString() {
BpmnBankConfigDTO dto = new BpmnBankConfigDTO(
UUID.randomUUID(), 1L, "acquirer", "branch", "terminal",
FunctionTypeEnum.MENU, new Timestamp(System.currentTimeMillis()),
new Timestamp(System.currentTimeMillis()), "creator", "updator");

String expectedToString = "BpmnBankConfigDTO(bpmnId=" + dto.getBpmnId() +
", bpmnModelVersion=" + dto.getBpmnModelVersion() +
", acquirerId=" + dto.getAcquirerId() +
", branchId=" + dto.getBranchId() +
", terminalId=" + dto.getTerminalId() +
", functionType=" + dto.getFunctionType() +
", createdAt=" + dto.getCreatedAt() +
", lastUpdatedAt=" + dto.getLastUpdatedAt() +
", createdBy=" + dto.getCreatedBy() +
", lastUpdatedBy=" + dto.getLastUpdatedBy() + ")";

assertEquals(expectedToString, dto.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
import java.util.UUID;
import java.sql.Timestamp;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;


public class BpmnDTOTest {

Expand Down

0 comments on commit 9d0a9ac

Please sign in to comment.