-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c02b6c7
commit 52cd174
Showing
2 changed files
with
209 additions
and
0 deletions.
There are no files selected for viewing
162 changes: 162 additions & 0 deletions
162
src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnDTOTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
package it.gov.pagopa.atmlayer.service.model.model; | ||
|
||
import it.gov.pagopa.atmlayer.service.model.enumeration.FunctionTypeEnum; | ||
import it.gov.pagopa.atmlayer.service.model.enumeration.StatusEnum; | ||
import org.junit.jupiter.api.Test; | ||
import java.util.UUID; | ||
import java.sql.Timestamp; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class BpmnDTOTest { | ||
|
||
@Test | ||
public void testGetterAndSetter() { | ||
BpmnDTO bpmnDTO = new BpmnDTO(); | ||
|
||
|
||
bpmnDTO.setBpmnId(UUID.randomUUID()); | ||
bpmnDTO.setModelVersion(1L); | ||
bpmnDTO.setDeployedFileName("example.bpmn"); | ||
bpmnDTO.setDefinitionKey("process_key"); | ||
bpmnDTO.setFunctionType(FunctionTypeEnum.MENU); | ||
bpmnDTO.setStatus(StatusEnum.CREATED); | ||
bpmnDTO.setSha256("hash123"); | ||
bpmnDTO.setDefinitionVersionCamunda(2); | ||
bpmnDTO.setCamundaDefinitionId("camunda123"); | ||
bpmnDTO.setDescription("BPMN Description"); | ||
bpmnDTO.setResourceFile(new ResourceFileDTO()); | ||
bpmnDTO.setResource("Resource Content"); | ||
bpmnDTO.setDeploymentId(UUID.randomUUID()); | ||
bpmnDTO.setCreatedAt(new Timestamp(System.currentTimeMillis())); | ||
bpmnDTO.setLastUpdatedAt(new Timestamp(System.currentTimeMillis())); | ||
bpmnDTO.setCreatedBy("User1"); | ||
bpmnDTO.setLastUpdatedBy("User2"); | ||
|
||
|
||
assertEquals(bpmnDTO.getBpmnId(), bpmnDTO.getBpmnId()); | ||
assertEquals(bpmnDTO.getModelVersion(), 1L); | ||
assertEquals(bpmnDTO.getDeployedFileName(), "example.bpmn"); | ||
assertEquals(bpmnDTO.getDefinitionKey(), "process_key"); | ||
assertEquals(bpmnDTO.getFunctionType(), FunctionTypeEnum.MENU); | ||
assertEquals(bpmnDTO.getStatus(), StatusEnum.CREATED); | ||
assertEquals(bpmnDTO.getSha256(), "hash123"); | ||
assertEquals(bpmnDTO.getDefinitionVersionCamunda(), 2); | ||
assertEquals(bpmnDTO.getCamundaDefinitionId(), "camunda123"); | ||
assertEquals(bpmnDTO.getDescription(), "BPMN Description"); | ||
assertEquals(bpmnDTO.getResourceFile(), new ResourceFileDTO()); | ||
assertEquals(bpmnDTO.getResource(), "Resource Content"); | ||
assertEquals(bpmnDTO.getDeploymentId(), bpmnDTO.getDeploymentId()); | ||
assertNotNull(bpmnDTO.getCreatedAt()); | ||
assertNotNull(bpmnDTO.getLastUpdatedAt()); | ||
assertEquals(bpmnDTO.getCreatedBy(), "User1"); | ||
assertEquals(bpmnDTO.getLastUpdatedBy(), "User2"); | ||
} | ||
|
||
@Test | ||
public void testNoArgsConstructor() { | ||
BpmnDTO bpmnDTO = new BpmnDTO(); | ||
assertNotNull(bpmnDTO); | ||
} | ||
|
||
@Test | ||
public void testAllArgsConstructor() { | ||
UUID bpmnId = UUID.randomUUID(); | ||
Long modelVersion = 2L; | ||
BpmnDTO bpmnDTO = new BpmnDTO(bpmnId, modelVersion, "file.bpmn", "key123", | ||
FunctionTypeEnum.SPONTANEOUS_PAYMENT, StatusEnum.DEPLOYED, "hash456", 3, | ||
"camunda456", "BPMN Description", new ResourceFileDTO(), | ||
"Resource Content", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), | ||
new Timestamp(System.currentTimeMillis()), "User3", "User4"); | ||
|
||
assertEquals(bpmnDTO.getBpmnId(), bpmnId); | ||
assertEquals(bpmnDTO.getModelVersion(), modelVersion); | ||
} | ||
|
||
@Test | ||
public void testBuilder() { | ||
BpmnDTO bpmnDTO = BpmnDTO.builder() | ||
.bpmnId(UUID.randomUUID()) | ||
.modelVersion(3L) | ||
.deployedFileName("file3.bpmn") | ||
.definitionKey("key789") | ||
.functionType(FunctionTypeEnum.SPONTANEOUS_PAYMENT) | ||
.status(StatusEnum.CREATED) | ||
.sha256("hash789") | ||
.definitionVersionCamunda(4) | ||
.camundaDefinitionId("camunda789") | ||
.description("BPMN Description 3") | ||
.resourceFile(new ResourceFileDTO()) | ||
.resource("Resource Content 3") | ||
.deploymentId(UUID.randomUUID()) | ||
.createdAt(new Timestamp(System.currentTimeMillis())) | ||
.lastUpdatedAt(new Timestamp(System.currentTimeMillis())) | ||
.createdBy("User5") | ||
.lastUpdatedBy("User6") | ||
.build(); | ||
|
||
assertNotNull(bpmnDTO); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
BpmnDTO bpmnDTO = BpmnDTO.builder() | ||
.bpmnId(UUID.randomUUID()) | ||
.modelVersion(4L) | ||
.deployedFileName("file4.bpmn") | ||
.definitionKey("key999") | ||
.functionType(FunctionTypeEnum.MENU) | ||
.status(StatusEnum.CREATED) | ||
.sha256("hash999") | ||
.definitionVersionCamunda(5) | ||
.camundaDefinitionId("camunda999") | ||
.description("BPMN Description 4") | ||
.resourceFile(new ResourceFileDTO()) | ||
.resource("Resource Content 4") | ||
.deploymentId(UUID.randomUUID()) | ||
.createdAt(new Timestamp(System.currentTimeMillis())) | ||
.lastUpdatedAt(new Timestamp(System.currentTimeMillis())) | ||
.createdBy("User7") | ||
.lastUpdatedBy("User8") | ||
.build(); | ||
|
||
String expectedToString = "BpmnDTO(bpmnId=" + bpmnDTO.getBpmnId() + | ||
", modelVersion=4, deployedFileName=file4.bpmn, definitionKey=key999, " + | ||
"functionType=MENU, status=CREATED, sha256=hash999, " + | ||
"definitionVersionCamunda=5, camundaDefinitionId=camunda999, " + | ||
"description=BPMN Description 4, resourceFile=ResourceFileDTO(id=null, resourceType=null, storageKey=null, fileName=null, extension=null, createdAt=null, lastUpdatedAt=null, createdBy=null, lastUpdatedBy=null), " + | ||
"resource=Resource Content 4, deploymentId=" + bpmnDTO.getDeploymentId() + | ||
", createdAt=" + bpmnDTO.getCreatedAt() + ", lastUpdatedAt=" + bpmnDTO.getLastUpdatedAt() + | ||
", createdBy=User7, lastUpdatedBy=User8)"; | ||
|
||
assertEquals(expectedToString, bpmnDTO.toString()); | ||
} | ||
|
||
@Test | ||
public void testEqualsAndHashCode() { | ||
BpmnDTO bpmnDTO1 = new BpmnDTO(UUID.randomUUID(), 1L, "file1.bpmn", "key1", | ||
FunctionTypeEnum.MENU, StatusEnum.CREATED, "hash1", 2, | ||
"camunda1", "BPMN Description 1", new ResourceFileDTO(), | ||
"Resource Content 1", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), | ||
new Timestamp(System.currentTimeMillis()), "User1", "User2"); | ||
|
||
BpmnDTO bpmnDTO2 = new BpmnDTO(UUID.randomUUID(), 1L, "file1.bpmn", "key1", | ||
FunctionTypeEnum.MENU, StatusEnum.CREATED, "hash1", 2, | ||
"camunda1", "BPMN Description 1", new ResourceFileDTO(), | ||
"Resource Content 1", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), | ||
new Timestamp(System.currentTimeMillis()), "User1", "User2"); | ||
|
||
assertEquals(bpmnDTO1, bpmnDTO1); | ||
assertNotEquals(bpmnDTO1, bpmnDTO2); | ||
|
||
assertNotEquals(bpmnDTO1, null); | ||
|
||
BpmnDTO bpmnDTO3 = new BpmnDTO(UUID.randomUUID(), 3L, "file3.bpmn", "key3", | ||
FunctionTypeEnum.SPONTANEOUS_PAYMENT, StatusEnum.DEPLOYED, "hash3", 4, | ||
"camunda3", "BPMN Description 3", new ResourceFileDTO(), | ||
"Resource Content 3", UUID.randomUUID(), new Timestamp(System.currentTimeMillis()), | ||
new Timestamp(System.currentTimeMillis()), "User3", "User4"); | ||
|
||
assertNotEquals(bpmnDTO1, bpmnDTO3); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/test/java/it/gov/pagopa/atmlayer/service/model/model/BpmnIdDtoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package it.gov.pagopa.atmlayer.service.model.model; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
|
||
public class BpmnIdDtoTest { | ||
|
||
@Test | ||
public void testEqualsAndHashCode() { | ||
BpmnIdDto dto1 = new BpmnIdDto(UUID.randomUUID(), 1L); | ||
BpmnIdDto dto2 = new BpmnIdDto(UUID.randomUUID(), 1L); | ||
|
||
assertEquals(dto1, dto1); | ||
assertNotEquals(dto1, dto2); | ||
assertNotEquals(dto1, null); | ||
|
||
BpmnIdDto dto3 = new BpmnIdDto(UUID.randomUUID(), 2L); | ||
assertNotEquals(dto1, dto3); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
UUID uuid = UUID.randomUUID(); | ||
BpmnIdDto dto = new BpmnIdDto(uuid, 1L); | ||
|
||
String expectedToString = "BpmnIdDto(bpmnId=" + uuid + ", modelVersion=1)"; | ||
assertEquals(expectedToString, dto.toString()); | ||
} | ||
|
||
@Test | ||
public void testGetterAndSetter() { | ||
BpmnIdDto dto = new BpmnIdDto(UUID.randomUUID(), 1L); | ||
|
||
UUID newUuid = UUID.randomUUID(); | ||
dto.setBpmnId(newUuid); | ||
assertEquals(newUuid, dto.getBpmnId()); | ||
|
||
Long newModelVersion = 2L; | ||
dto.setModelVersion(newModelVersion); | ||
assertEquals(newModelVersion, dto.getModelVersion()); | ||
} | ||
} | ||
|