0

According to the Pitest report, the following negated conditional has survived

enter image description here

Why I find this odd is because I have 2 unit tests, one testing condition where channelType does equal WEB and another unit test where channelType equals MOBILE. What am I missing here?

@Test
void process() {
  AutoDepositRegistration autoDepositRegistration = createDefaultAutoDepositRegistration(RegistrationActions.ADD_AUTO_DEPOSIT_REGISTRATION,
          AutoDepositRegistration.ChannelTypeEnum.WEB);
  ResponseEntity<CreateAccountAliasRegistrationResponse> responseEntity = createResponseEntity();

  when(messageService.forwardToStream(eq(MessageType.AUTODEPOSITREGISTRATION.getValue()), any(), any(), any())).thenReturn(true);
  when(faultToleranceInteracRegistrationClient.createAccountAliasRegistration(any(), any(), any(), any(ChannelIndicator.class),
          any(), any(), any(), any(), any(), any())).thenReturn(responseEntity);

  addAutoDepositRegistration.process(autoDepositRegistration);

  assertNull(autoDepositRegistration.getError());
  assertEquals(PROCESSED, autoDepositRegistration.getAutoDepositRegistrationStatus());
  assertEquals(ACCOUNT_ALIAS_REFERENCE, autoDepositRegistration.getAutoDepositRegistrationInfos().get(0).getAutoDepositRegistrationId());
}

@Test
void process_clientType_mobile() {
  AutoDepositRegistration autoDepositRegistration = createDefaultAutoDepositRegistration(RegistrationActions.ADD_AUTO_DEPOSIT_REGISTRATION,
          AutoDepositRegistration.ChannelTypeEnum.MOBILE);
  ResponseEntity<CreateAccountAliasRegistrationResponse> responseEntity = createResponseEntity();

  when(messageService.forwardToStream(eq(MessageType.AUTODEPOSITREGISTRATION.getValue()), any(), any(), any())).thenReturn(true);
  when(faultToleranceInteracRegistrationClient.createAccountAliasRegistration(any(), any(), any(), any(ChannelIndicator.class),
          any(), any(), any(), any(), any(), any())).thenReturn(responseEntity);

  addAutoDepositRegistration.process(autoDepositRegistration);

  assertNull(autoDepositRegistration.getError());
  assertEquals(PROCESSED, autoDepositRegistration.getAutoDepositRegistrationStatus());
  assertEquals(ACCOUNT_ALIAS_REFERENCE, autoDepositRegistration.getAutoDepositRegistrationInfos().get(0).getAutoDepositRegistrationId());
}
Steve B
  • 557
  • 2
  • 7
  • 23
  • It's hard to say why it failed, since you didn't post full code. A _possible_ reason is `any(ChannelIndicator.class)`. Try replacing this argument matcher with `is(ChannelIndicator.ONLINE)` in one test and `is(ChannelIndicator.MOBILE)` in the other one. – Alex Shesterov Jun 09 '21 at 19:24
  • did you mean isA? When I try isA(ChannelIndicator.ONLINE), I get an error saying that "required type Class , provided ChannelIndicator. – Steve B Jun 09 '21 at 19:39
  • sorry, I meant `eq()` of course... `org.mockito.ArgumentMatchers.eq()`. Too tired and lost my concentration :) – Alex Shesterov Jun 09 '21 at 19:52
  • YES! eq did the trick. thank you! – Steve B Jun 09 '21 at 20:10

0 Answers0