Skip to content

Commit

Permalink
extend test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rohwerj committed Apr 5, 2024
1 parent d75f5d7 commit b506419
Show file tree
Hide file tree
Showing 14 changed files with 405 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.BatchDto
import org.junit.Test
import java.time.OffsetDateTime

class BatchAdapterTest {
private val dto = BatchDto()
.id("id")
.tenantId("tenantId")
.type("type")
.totalJobs(1)
.jobsCreated(1)
.batchJobsPerSeed(1)
.invocationsPerBatchJob(1)
.batchJobDefinitionId("batchJobDefinitionId")
.seedJobDefinitionId("seedJobDefinitionId")
.monitorJobDefinitionId("monitorJobDefinitionId")
.suspended(false)
.createUserId("createUserId")
.startTime(OffsetDateTime.now())
.executionStartTime(OffsetDateTime.now())

@Test
fun `should delegate`() {
val batchBean = BatchBean.fromDto(dto)
val batchAdapter = BatchAdapter(batchBean)
Assertions.assertThat(batchAdapter).usingRecursiveComparison().ignoringFields("batchBean").isEqualTo(batchBean)
}

@Test
fun `should construct from dto`() {
val bean = BatchBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("startTime", "executionStartTime").isEqualTo(dto)
Assertions.assertThat(bean.startTime).isEqualTo(dto.startTime.toInstant())
Assertions.assertThat(bean.executionStartTime).isEqualTo(dto.executionStartTime.toInstant())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.AtomLink
import org.camunda.community.rest.client.model.DeploymentDto
import org.junit.Test
import java.time.OffsetDateTime

class DeploymentAdapterTest {
private val dto = DeploymentDto()
.id("id")
.tenantId("tenantId")
.links(listOf(AtomLink()))
.deploymentTime(OffsetDateTime.now())
.source("source")
.name("name")

@Test
fun `should delegate`() {
val bean = DeploymentBean.fromDto(dto)
val adapter = DeploymentAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("deploymentBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = DeploymentBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("deploymentTime", "deployedProcessDefinitions",
"deployedCaseDefinitions", "deployedDecisionDefinitions", "deployedDecisionRequirementsDefinitions").isEqualTo(dto)
Assertions.assertThat(bean.deploymentTime).isEqualTo(dto.deploymentTime.toInstant())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.EventSubscriptionDto
import org.junit.Test
import java.time.OffsetDateTime

class EventSubscriptionAdapterTest {
private val dto = EventSubscriptionDto()
.id("id")
.tenantId("tenantId")
.eventType("eventType")
.eventName("eventName")
.executionId("executionId")
.processInstanceId("processInstanceId")
.activityId("activityId")
.createdDate(OffsetDateTime.now())

@Test
fun `should delegate`() {
val bean = EventSubscriptionBean.fromDto(dto)
val adapter = EventSubscriptionAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("eventSubscriptionBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = EventSubscriptionBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("createdDate").isEqualTo(dto)
Assertions.assertThat(bean.createdDate).isEqualTo(dto.createdDate.toInstant())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.HistoricProcessInstanceDto
import org.junit.Test
import java.time.OffsetDateTime

class HistoricProcessInstanceAdapterTest {
private val dto = HistoricProcessInstanceDto()
.id("id")
.tenantId("tenantId")
.rootProcessInstanceId("rootProcessInstanceId")
.superProcessInstanceId("superProcessInstanceId")
.superCaseInstanceId("superCaseInstanceId")
.caseInstanceId("caseInstanceId")
.processDefinitionName("processDefinitionName")
.processDefinitionKey("processDefinitionKey")
.processDefinitionVersion(1)
.processDefinitionId("processDefinitionId")
.businessKey("businessKey")
.startTime(OffsetDateTime.now())
.endTime(OffsetDateTime.now())
.removalTime(OffsetDateTime.now())
.durationInMillis(1000)
.startUserId("startUserId")
.startActivityId("startActivityId")
.deleteReason("deleteReason")
.state(HistoricProcessInstanceDto.StateEnum.ACTIVE)


@Test
fun `should delegate`() {
val bean = HistoricInstanceBean.fromHistoricProcessInstanceDto(dto)
val adapter = HistoricProcessInstanceAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("historicInstanceBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = HistoricInstanceBean.fromHistoricProcessInstanceDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("startTime", "endTime", "removalTime", "endActivityId", "state").isEqualTo(dto)
Assertions.assertThat(bean.startTime).isEqualTo(dto.startTime.toInstant())
Assertions.assertThat(bean.endTime).isEqualTo(dto.endTime.toInstant())
Assertions.assertThat(bean.removalTime).isEqualTo(dto.removalTime.toInstant())
Assertions.assertThat(bean.state).isEqualTo(dto.state.name)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*-
* #%L
* camunda-platform-7-rest-client-spring-boot
* %%
* Copyright (C) 2019 Camunda Services GmbH
* %%
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions.assertThat
import org.camunda.community.rest.client.model.IdentityLinkDto
import org.junit.Test

class IdentityLinkAdapterTest {

private val dto = IdentityLinkDto()
.userId("userId")
.groupId("groupId")
.type("candidate")

@Test
fun `should delegate`() {
val bean = IdentityLinkBean.fromDto("taskId", dto)
val adapter = IdentityLinkAdapter(bean)
assertThat(adapter).usingRecursiveComparison().ignoringFields("identityLinkBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = IdentityLinkBean.fromDto("taskId", dto)
assertThat(bean).usingRecursiveComparison().ignoringFields("processDefinitionId", "tenantId", "id", "taskId").isEqualTo(dto)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.IncidentDto
import org.junit.Test
import java.time.OffsetDateTime

class IncidentAdapterTest {
private val dto = IncidentDto()
.id("id")
.tenantId("tenantId")
.processDefinitionId("processDefinitionId")
.processInstanceId("processInstanceId")
.executionId("executionId")
.incidentTimestamp(OffsetDateTime.now())
.incidentType("incidentType")
.activityId("activityId")
.failedActivityId("failedActivityId")
.causeIncidentId("causeIncidentId")
.rootCauseIncidentId("rootCauseIncidentId")
._configuration("_configuration")
.tenantId("tenantId")
.incidentMessage("incidentMessage")
.jobDefinitionId("jobDefinitionId")
.annotation("annotation")

@Test
fun `should delegate`() {
val bean = IncidentBean.fromDto(dto)
val adapter = IncidentAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("incidentBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = IncidentBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("incidentTimestamp", "configuration", "historyConfiguration").isEqualTo(dto)
Assertions.assertThat(bean.incidentTimestamp).isEqualTo(dto.incidentTimestamp.toInstant())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.ProcessDefinitionDto
import org.junit.Test

class ProcessDefinitionAdapterTest {
private val dto = ProcessDefinitionDto()
.id("id")
.tenantId("tenantId")
.key("key")
.category("category")
.description("description")
.name("name")
.version(1)
.resource("resource")
.deploymentId("deploymentId")
.diagram("diagram")
.suspended(false)
.tenantId("tenantId")
.versionTag("versionTag")
.historyTimeToLive(1)
.startableInTasklist(true)


@Test
fun `should delegate`() {
val bean = ProcessDefinitionBean.fromDto(dto)
val adapter = ProcessDefinitionAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("processDefinitionBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = ProcessDefinitionBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("resourceName", "diagramResourceName", "startableInTaskList", "hasStartFormKey").isEqualTo(dto)
Assertions.assertThat(bean.startableInTaskList).isEqualTo(dto.startableInTasklist)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.camunda.community.rest.adapter

import org.assertj.core.api.Assertions
import org.camunda.community.rest.client.model.CamundaFormRef
import org.camunda.community.rest.client.model.TaskDto
import org.junit.Test
import java.time.OffsetDateTime

class TaskAdapterTest {
private val dto = TaskDto()
.id("id")
.tenantId("tenantId")
.name("name")
.assignee("assignee")
.owner("owner")
.created(OffsetDateTime.now())
.lastUpdated(OffsetDateTime.now())
.due(OffsetDateTime.now())
.followUp(OffsetDateTime.now())
.delegationState(TaskDto.DelegationStateEnum.RESOLVED)
.description("description")
.executionId("executionId")
.parentTaskId("parentTaskId")
.priority(1)
.processDefinitionId("processDefinitionId")
.processInstanceId("processInstanceId")
.caseExecutionId("caseExecutionId")
.caseDefinitionId("caseDefinitionId")
.caseInstanceId("caseInstanceId")
.taskDefinitionKey("taskDefinitionKey")
.suspended(false)
.formKey("formKey")
.camundaFormRef(CamundaFormRef().key("key").binding("binding").version(1))


@Test
fun `should delegate`() {
val bean = TaskBean.fromDto(dto)
val adapter = TaskAdapter(bean)
Assertions.assertThat(adapter).usingRecursiveComparison().ignoringFields("taskBean").isEqualTo(bean)
}

@Test
fun `should construct from dto`() {
val bean = TaskBean.fromDto(dto)
Assertions.assertThat(bean).usingRecursiveComparison().ignoringFields("created", "lastUpdated", "due", "followUp", "processExecutionId").isEqualTo(dto)
Assertions.assertThat(bean.created).isEqualTo(dto.created.toInstant())
Assertions.assertThat(bean.lastUpdated).isEqualTo(dto.lastUpdated.toInstant())
Assertions.assertThat(bean.due).isEqualTo(dto.due.toInstant())
Assertions.assertThat(bean.followUp).isEqualTo(dto.followUp.toInstant())
}
}
Loading

0 comments on commit b506419

Please sign in to comment.