From 68a4953719b14a47070d3f7f95bfc198b8b5b556 Mon Sep 17 00:00:00 2001 From: salander85 Date: Wed, 29 Nov 2023 16:21:58 +0100 Subject: [PATCH] Increase coverage --- .../StateReferenceResolutionUtilsTest.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/commercetools/sync/states/utils/StateReferenceResolutionUtilsTest.java b/src/test/java/com/commercetools/sync/states/utils/StateReferenceResolutionUtilsTest.java index 394adde050..07c70ab935 100644 --- a/src/test/java/com/commercetools/sync/states/utils/StateReferenceResolutionUtilsTest.java +++ b/src/test/java/com/commercetools/sync/states/utils/StateReferenceResolutionUtilsTest.java @@ -126,11 +126,27 @@ void mapToStateDrafts_WithMissingRequiredFields_ShouldNotFailAndReturnEmptyDraft final State mockState = mock(State.class); when(mockState.getTransitions()).thenReturn(null); - // test - final List referenceReplacedDrafts = - StateReferenceResolutionUtils.mapToStateDrafts(List.of(mockState), referenceIdToKeyCache); - - assertThat(referenceReplacedDrafts.get(0)).isEqualTo(StateDraft.of()); + // asserts + assertThat( + StateReferenceResolutionUtils.mapToStateDrafts( + List.of(mockState), referenceIdToKeyCache) + .get(0)) + .isEqualTo(StateDraft.of()); + + when(mockState.getKey()).thenReturn("Any key"); + assertThat( + StateReferenceResolutionUtils.mapToStateDrafts( + List.of(mockState), referenceIdToKeyCache) + .get(0)) + .isEqualTo(StateDraft.of()); + + when(mockState.getKey()).thenReturn(null); + when(mockState.getType()).thenReturn(StateTypeEnum.LINE_ITEM_STATE); + assertThat( + StateReferenceResolutionUtils.mapToStateDrafts( + List.of(mockState), referenceIdToKeyCache) + .get(0)) + .isEqualTo(StateDraft.of()); } @Nonnull