### Question:
TppOperationInfoService { public List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType) { String tppId = validateAndGetTppId(); List<OperationInfoEntity> infos = Optional.ofNullable(operationType) .map(o -> infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(tppId, OperationTypeEntity.valueOf(o.name()))) .orElseGet(() -> infoRepository.findAllByTppIdOrderByCreatedDesc(tppId)); return infoMapper.toOperationInfos(infos); }  List<OperationInfo> getOperationsByTypeAndTppId(OperationType operationType); OperationInfo createInfo(OperationInfo operationInfo); void deleteInfo(Long operationInfoId);  }### Answer:
@Test void getOperationsByTypeAndTppId() { when(userMgmtRestClient.getUser()).thenReturn(ResponseEntity.ok(getUser(UserRoleTO.STAFF))); when(infoRepository.findAllByTppIdAndOperationTypeOrderByCreatedDesc(anyString(), any())).thenReturn(getOperationInfos()); when(infoMapper.toOperationInfos(anyList())).thenAnswer(a -> MAPPER.toOperationInfos(a.getArgument(0))); List<OperationInfo> result = service.getOperationsByTypeAndTppId(OperationType.CONSENT); assertEquals(MAPPER.toOperationInfos(getOperationInfos()), result); }
@Test void getOperationsByTypeAndTppId_user_is_not_tpp() { when(userMgmtRestClient.getUser()).thenReturn(ResponseEntity.ok(getUser(UserRoleTO.CUSTOMER))); assertThrows(TppException.class, () -> service.getOperationsByTypeAndTppId(OperationType.CONSENT)); }