This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
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
53fa2da
commit ffb4ffd
Showing
6 changed files
with
4 additions
and
262 deletions.
There are no files selected for viewing
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
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
70 changes: 0 additions & 70 deletions
70
...t/java/com/redhat/parodos/tasks/project/ProjectAccessRequestApprovalWorkFlowTaskTest.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 |
---|---|---|
@@ -1,75 +1,5 @@ | ||
package com.redhat.parodos.tasks.project; | ||
|
||
import java.util.UUID; | ||
|
||
import com.redhat.parodos.infrastructure.Notifier; | ||
import com.redhat.parodos.infrastructure.ProjectRequester; | ||
import com.redhat.parodos.workflow.exception.MissingParameterException; | ||
import com.redhat.parodos.workflows.work.WorkContext; | ||
import com.redhat.parodos.workflows.work.WorkReport; | ||
import com.redhat.parodos.workflows.work.WorkStatus; | ||
import lombok.SneakyThrows; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.doNothing; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.doThrow; | ||
import static org.mockito.Mockito.spy; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ProjectAccessRequestApprovalWorkFlowTaskTest { | ||
|
||
private static final String ACCESS_REQUEST_ID_PARAMETER_NAME = "ACCESS_REQUEST_ID"; | ||
|
||
private static final String ACCESS_REQUEST_APPROVAL_USERNAMES_PARAMETER_NAME = "ACCESS_REQUEST_APPROVAL_USERNAMES"; | ||
|
||
private static final String ACCESS_REQUEST_APPROVAL_USERNAMES_VALUE_TEST = "approval-username-test"; | ||
|
||
@Mock | ||
private ProjectRequester projectRequester; | ||
|
||
@Mock | ||
private Notifier notifier; | ||
|
||
private WorkContext workContext; | ||
|
||
private ProjectAccessRequestApprovalWorkFlowTask projectAccessRequestApprovalWorkFlowTask; | ||
|
||
@Before | ||
public void setUp() { | ||
this.projectAccessRequestApprovalWorkFlowTask = spy( | ||
new ProjectAccessRequestApprovalWorkFlowTask(projectRequester, notifier)); | ||
this.projectAccessRequestApprovalWorkFlowTask.setBeanName("projectAccessRequestApprovalWorkFlowTask"); | ||
workContext = new WorkContext(); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void executeSuccess() { | ||
doReturn(String.valueOf(UUID.randomUUID())).when(this.projectAccessRequestApprovalWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
doReturn(ACCESS_REQUEST_APPROVAL_USERNAMES_VALUE_TEST).when(this.projectAccessRequestApprovalWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_APPROVAL_USERNAMES_PARAMETER_NAME)); | ||
doNothing().when(notifier).send(any()); | ||
|
||
WorkReport workReport = projectAccessRequestApprovalWorkFlowTask.execute(workContext); | ||
assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void executeFail() { | ||
doThrow(MissingParameterException.class).when(this.projectAccessRequestApprovalWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
WorkReport workReport = projectAccessRequestApprovalWorkFlowTask.execute(workContext); | ||
assertEquals(WorkStatus.FAILED, workReport.getStatus()); | ||
} | ||
|
||
} |
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
107 changes: 0 additions & 107 deletions
107
...at/parodos/tasks/project/checker/ProjectAccessRequestApprovalWorkFlowCheckerTaskTest.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 |
---|---|---|
@@ -1,112 +1,5 @@ | ||
package com.redhat.parodos.tasks.project.checker; | ||
|
||
import java.util.UUID; | ||
|
||
import com.redhat.parodos.infrastructure.ProjectRequester; | ||
import com.redhat.parodos.sdk.model.AccessStatusResponseDTO; | ||
import com.redhat.parodos.workflow.exception.MissingParameterException; | ||
import com.redhat.parodos.workflow.utils.WorkContextUtils; | ||
import com.redhat.parodos.workflows.work.WorkContext; | ||
import com.redhat.parodos.workflows.work.WorkReport; | ||
import com.redhat.parodos.workflows.work.WorkStatus; | ||
import com.redhat.parodos.workflows.workflow.WorkFlow; | ||
import lombok.SneakyThrows; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.doThrow; | ||
import static org.mockito.Mockito.spy; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ProjectAccessRequestApprovalWorkFlowCheckerTaskTest { | ||
|
||
private static final String ACCESS_REQUEST_ID_PARAMETER_NAME = "ACCESS_REQUEST_ID"; | ||
|
||
private static final long SLA_TEST = 100L; | ||
|
||
@Mock | ||
private ProjectRequester projectRequester; | ||
|
||
@Mock | ||
private WorkFlow workFlow; | ||
|
||
private WorkContext workContext; | ||
|
||
private ProjectAccessRequestApprovalWorkFlowCheckerTask projectAccessRequestApprovalWorkFlowCheckerTask; | ||
|
||
@Before | ||
public void setUp() { | ||
this.projectAccessRequestApprovalWorkFlowCheckerTask = spy( | ||
new ProjectAccessRequestApprovalWorkFlowCheckerTask(workFlow, SLA_TEST, projectRequester)); | ||
this.projectAccessRequestApprovalWorkFlowCheckerTask | ||
.setBeanName("projectAccessRequestApprovalWorkFlowCheckerTask"); | ||
workContext = new WorkContext(); | ||
WorkContextUtils.setProjectId(workContext, UUID.randomUUID()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void checkWorkFlowStatusCompleted() { | ||
UUID accessRequestId = UUID.randomUUID(); | ||
doReturn(String.valueOf(accessRequestId)).when(this.projectAccessRequestApprovalWorkFlowCheckerTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
|
||
AccessStatusResponseDTO accessStatusResponseDTO = new AccessStatusResponseDTO(); | ||
accessStatusResponseDTO.setAccessRequestId(accessRequestId); | ||
accessStatusResponseDTO.setStatus(AccessStatusResponseDTO.StatusEnum.APPROVED); | ||
when(projectRequester.getAccessStatus(any())).thenReturn(accessStatusResponseDTO); | ||
|
||
WorkReport workReport = projectAccessRequestApprovalWorkFlowCheckerTask.execute(workContext); | ||
assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void checkWorkFlowStatusRejected() { | ||
UUID accessRequestId = UUID.randomUUID(); | ||
doReturn(String.valueOf(accessRequestId)).when(this.projectAccessRequestApprovalWorkFlowCheckerTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
|
||
AccessStatusResponseDTO accessStatusResponseDTO = new AccessStatusResponseDTO(); | ||
accessStatusResponseDTO.setAccessRequestId(accessRequestId); | ||
accessStatusResponseDTO.setStatus(AccessStatusResponseDTO.StatusEnum.REJECTED); | ||
when(projectRequester.getAccessStatus(any())).thenReturn(accessStatusResponseDTO); | ||
|
||
WorkReport workReport = projectAccessRequestApprovalWorkFlowCheckerTask.execute(workContext); | ||
assertEquals(WorkStatus.REJECTED, workReport.getStatus()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void checkWorkFlowStatusPending() { | ||
UUID accessRequestId = UUID.randomUUID(); | ||
doReturn(String.valueOf(accessRequestId)).when(this.projectAccessRequestApprovalWorkFlowCheckerTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
|
||
AccessStatusResponseDTO accessStatusResponseDTO = new AccessStatusResponseDTO(); | ||
accessStatusResponseDTO.setAccessRequestId(accessRequestId); | ||
accessStatusResponseDTO.setStatus(AccessStatusResponseDTO.StatusEnum.PENDING); | ||
when(projectRequester.getAccessStatus(any())).thenReturn(accessStatusResponseDTO); | ||
|
||
WorkReport workReport = projectAccessRequestApprovalWorkFlowCheckerTask.execute(workContext); | ||
assertEquals(WorkStatus.FAILED, workReport.getStatus()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void executeFailForMissingRequiredParameter() { | ||
doThrow(MissingParameterException.class).when(this.projectAccessRequestApprovalWorkFlowCheckerTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
WorkReport workReport = projectAccessRequestApprovalWorkFlowCheckerTask.execute(workContext); | ||
assertEquals(WorkStatus.FAILED, workReport.getStatus()); | ||
} | ||
|
||
} |
70 changes: 0 additions & 70 deletions
70
...dhat/parodos/tasks/project/escalation/ProjectAccessRequestEscalationWorkFlowTaskTest.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 |
---|---|---|
@@ -1,75 +1,5 @@ | ||
package com.redhat.parodos.tasks.project.escalation; | ||
|
||
import java.util.UUID; | ||
|
||
import com.redhat.parodos.infrastructure.Notifier; | ||
import com.redhat.parodos.infrastructure.ProjectRequester; | ||
import com.redhat.parodos.workflow.exception.MissingParameterException; | ||
import com.redhat.parodos.workflows.work.WorkContext; | ||
import com.redhat.parodos.workflows.work.WorkReport; | ||
import com.redhat.parodos.workflows.work.WorkStatus; | ||
import lombok.SneakyThrows; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.doNothing; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.doThrow; | ||
import static org.mockito.Mockito.spy; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ProjectAccessRequestEscalationWorkFlowTaskTest { | ||
|
||
private static final String ACCESS_REQUEST_ID_PARAMETER_NAME = "ACCESS_REQUEST_ID"; | ||
|
||
private static final String ACCESS_REQUEST_ESCALATION_USERNAME_PARAMETER_NAME = "ACCESS_REQUEST_ESCALATION_USERNAME"; | ||
|
||
private static final String ACCESS_REQUEST_ESCALATION_USERNAME_VALUE_TEST = "escalation-username-test"; | ||
|
||
@Mock | ||
private ProjectRequester projectRequester; | ||
|
||
@Mock | ||
private Notifier notifier; | ||
|
||
private WorkContext workContext; | ||
|
||
private ProjectAccessRequestEscalationWorkFlowTask projectAccessRequestEscalationWorkFlowTask; | ||
|
||
@Before | ||
public void setUp() { | ||
this.projectAccessRequestEscalationWorkFlowTask = spy( | ||
new ProjectAccessRequestEscalationWorkFlowTask(projectRequester, notifier)); | ||
this.projectAccessRequestEscalationWorkFlowTask.setBeanName("projectAccessRequestEscalationWorkFlowTask"); | ||
workContext = new WorkContext(); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void executeSuccess() { | ||
doReturn(String.valueOf(UUID.randomUUID())).when(this.projectAccessRequestEscalationWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
doReturn(ACCESS_REQUEST_ESCALATION_USERNAME_VALUE_TEST).when(this.projectAccessRequestEscalationWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ESCALATION_USERNAME_PARAMETER_NAME)); | ||
doNothing().when(notifier).send(any()); | ||
|
||
WorkReport workReport = projectAccessRequestEscalationWorkFlowTask.execute(workContext); | ||
assertEquals(WorkStatus.COMPLETED, workReport.getStatus()); | ||
} | ||
|
||
@Test | ||
@SneakyThrows | ||
public void executeFail() { | ||
doThrow(MissingParameterException.class).when(this.projectAccessRequestEscalationWorkFlowTask) | ||
.getRequiredParameterValue(eq(ACCESS_REQUEST_ID_PARAMETER_NAME)); | ||
WorkReport workReport = projectAccessRequestEscalationWorkFlowTask.execute(workContext); | ||
assertEquals(WorkStatus.FAILED, workReport.getStatus()); | ||
} | ||
|
||
} |