CheckValidityAsyncOperationActor { public void check(final CheckValidityMessage message) throws InvalidAsyncOperationIdException { try { List<String> validIds = message.getIdentifiers(); if (validIds == null || validIds.isEmpty()) { throw new InvalidAsyncOperationIdException("List of valid id is empty"); } if (!validIds.contains(message.getAsyncOperationId())) { throw new InvalidAsyncOperationIdException("List of async operations does not contain operation with received token"); } } catch (ReadValueException e) { throw new InvalidAsyncOperationIdException(e); } } CheckValidityAsyncOperationActor(final IObject config); void check(final CheckValidityMessage message);  }
@Test(expected = InvalidAsyncOperationIdException.class) public void Should_ThrowException_When_InvalidId() throws ReadValueException, ChangeValueException, InvalidAsyncOperationIdException { PowerMockito.when(message.getIdentifiers()).thenReturn(Arrays.asList("111", "222", "333")); PowerMockito.when(message.getAsyncOperationId()).thenReturn("000"); actor.check(message); }
@Test(expected = InvalidAsyncOperationIdException.class) public void Should_ThrowException_When_ListOfIdsIsNull() throws ChangeValueException, ReadValueException, InvalidAsyncOperationIdException { PowerMockito.when(message.getIdentifiers()).thenReturn(null); PowerMockito.when(message.getAsyncOperationId()).thenReturn("000"); actor.check(message); }
@Test(expected = InvalidAsyncOperationIdException.class) public void Should_ThrowException_When_ListOfIdsIsEmpty() throws ChangeValueException, ReadValueException, InvalidAsyncOperationIdException { PowerMockito.when(message.getIdentifiers()).thenReturn(new ArrayList<>()); PowerMockito.when(message.getAsyncOperationId()).thenReturn("000"); actor.check(message); }