@Test void testReleaseLock() { Operation.State abortedState = Operation.State.ABORTED; processConflictPreventerMock.releaseLock(testProcessId, abortedState); ArgumentCaptor<Operation> argumentCaptor = ArgumentCaptor.forClass(Operation.class); verify(operationServiceMock).update(argumentCaptor.capture(), argThat(this::assertOperationAbort)); assertEquals(testProcessId, argumentCaptor.getValue() .getProcessId()); }
public void releaseLock(String processInstanceId, Operation.State state) { Operation operation = getOperationByProcessId(processInstanceId); LOGGER.info(MessageFormat.format(Messages.PROCESS_0_RELEASING_LOCK_FOR_MTA_1_IN_SPACE_2, operation.getProcessId(), operation.getMtaId(), operation.getSpaceId())); operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .endedAt(ZonedDateTime.now()) .build(); operationService.update(operation, operation); LOGGER.debug(MessageFormat.format(Messages.PROCESS_0_RELEASED_LOCK, operation.getProcessId())); }
ProcessConflictPreventer { public void releaseLock(String processInstanceId, Operation.State state) { Operation operation = getOperationByProcessId(processInstanceId); LOGGER.info(MessageFormat.format(Messages.PROCESS_0_RELEASING_LOCK_FOR_MTA_1_IN_SPACE_2, operation.getProcessId(), operation.getMtaId(), operation.getSpaceId())); operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .endedAt(ZonedDateTime.now()) .build(); operationService.update(operation, operation); LOGGER.debug(MessageFormat.format(Messages.PROCESS_0_RELEASED_LOCK, operation.getProcessId())); } }
ProcessConflictPreventer { public void releaseLock(String processInstanceId, Operation.State state) { Operation operation = getOperationByProcessId(processInstanceId); LOGGER.info(MessageFormat.format(Messages.PROCESS_0_RELEASING_LOCK_FOR_MTA_1_IN_SPACE_2, operation.getProcessId(), operation.getMtaId(), operation.getSpaceId())); operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .endedAt(ZonedDateTime.now()) .build(); operationService.update(operation, operation); LOGGER.debug(MessageFormat.format(Messages.PROCESS_0_RELEASED_LOCK, operation.getProcessId())); } ProcessConflictPreventer(OperationService operationService); }
ProcessConflictPreventer { public void releaseLock(String processInstanceId, Operation.State state) { Operation operation = getOperationByProcessId(processInstanceId); LOGGER.info(MessageFormat.format(Messages.PROCESS_0_RELEASING_LOCK_FOR_MTA_1_IN_SPACE_2, operation.getProcessId(), operation.getMtaId(), operation.getSpaceId())); operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .endedAt(ZonedDateTime.now()) .build(); operationService.update(operation, operation); LOGGER.debug(MessageFormat.format(Messages.PROCESS_0_RELEASED_LOCK, operation.getProcessId())); } ProcessConflictPreventer(OperationService operationService); synchronized void acquireLock(String mtaId, String namespace, String spaceId, String processId); void releaseLock(String processInstanceId, Operation.State state); }
ProcessConflictPreventer { public void releaseLock(String processInstanceId, Operation.State state) { Operation operation = getOperationByProcessId(processInstanceId); LOGGER.info(MessageFormat.format(Messages.PROCESS_0_RELEASING_LOCK_FOR_MTA_1_IN_SPACE_2, operation.getProcessId(), operation.getMtaId(), operation.getSpaceId())); operation = ImmutableOperation.builder() .from(operation) .hasAcquiredLock(false) .state(state) .endedAt(ZonedDateTime.now()) .build(); operationService.update(operation, operation); LOGGER.debug(MessageFormat.format(Messages.PROCESS_0_RELEASED_LOCK, operation.getProcessId())); } ProcessConflictPreventer(OperationService operationService); synchronized void acquireLock(String mtaId, String namespace, String spaceId, String processId); void releaseLock(String processInstanceId, Operation.State state);  }