| | |
| | | |
| | | import java.lang.reflect.Constructor; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | |
| | | } |
| | | |
| | | @Test |
| | | void doubleExtension_shouldFallBackWhenSameStandby1DeepLocHasNoEmptyShallowPartner() { |
| | | void doubleExtension_shouldReturnShallowLocWhenDeepLocContainsEmptyPallet() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionProfile(); |
| | | when(basCrnDepthRuleService.resolveProfile(rowLastno, 1, 2)).thenReturn(profile); |
| | | |
| | | LocMast deepLoc = buildLoc("D-002", 1, 1, 1, "F", 1); |
| | | LocMast shallowLoc = buildLoc("S-002", 2, 1, 1, "O", 1); |
| | | LocDetl deepDetl = buildDetl("D-002", "PO-002"); |
| | | deepDetl.setMatnr("emptyPallet"); |
| | | |
| | | when(locMastService.selectList(any())).thenReturn(Arrays.asList(deepLoc)); |
| | | when(locDetlService.selectList(any())).thenReturn(Arrays.asList(deepDetl)); |
| | | when(locMastService.selectOne(any())).thenReturn(shallowLoc); |
| | | |
| | | FindLocNoAttributeVo attributeVo = buildAttributeVo("PO-002"); |
| | | attributeVo.setMatnr("emptyPallet"); |
| | | |
| | | LocMast result = ReflectionTestUtils.invokeMethod(commonService, "findConfiguredEmptyLocForCrn", |
| | | rowLastno, buildRowLastnoType(), 1, 2, null, attributeVo, false); |
| | | |
| | | assertEquals("S-002", result.getLocNo()); |
| | | assertEquals(Integer.valueOf(2), result.getRow1()); |
| | | assertEquals("O", result.getLocSts()); |
| | | } |
| | | |
| | | @Test |
| | | void orderDoubleExtensionShallowRows_shouldPreferLessLoadedPair() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionTwoPairProfile(); |
| | | when(locMastService.selectCount(any())).thenReturn(2, 2, 0, 0); |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | List<Integer> orderedRows = ReflectionTestUtils.invokeMethod(commonService, "orderDoubleExtensionShallowRows", |
| | | rowLastno, buildRowLastnoType(), 1, profile); |
| | | |
| | | assertEquals(Arrays.asList(3, 2), orderedRows); |
| | | } |
| | | |
| | | @Test |
| | | void orderDoubleExtensionShallowRows_shouldRotateEqualLoadPairByCurrentRow() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionTwoPairProfile(); |
| | | when(locMastService.selectCount(any())).thenReturn(1, 1, 1, 1); |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | List<Integer> orderedRows = ReflectionTestUtils.invokeMethod(commonService, "orderDoubleExtensionShallowRows", |
| | | rowLastno, buildRowLastnoType(), 1, profile); |
| | | |
| | | assertEquals(Arrays.asList(3, 2), orderedRows); |
| | | } |
| | | |
| | | @Test |
| | | void doubleExtension_shouldSwitchPairAfterReservationLoadIncreases() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionTwoPairProfile(); |
| | | when(basCrnDepthRuleService.resolveProfile(rowLastno, 1, 2)).thenReturn(profile); |
| | | |
| | | when(locMastService.selectCount(any())).thenReturn( |
| | | 1, 1, 1, 1, |
| | | 1, 1, 1, 2); |
| | | LocMast firstPairShallowLoc = buildLoc("S-003", 3, 1, 1, "O", 1); |
| | | LocMast firstPairDeepLoc = buildLoc("D-004", 4, 1, 1, "O", 1); |
| | | LocMast secondPairShallowLoc = buildLoc("S-002", 2, 1, 1, "O", 1); |
| | | LocMast secondPairDeepLoc = buildLoc("D-001", 1, 1, 1, "O", 1); |
| | | when(locMastService.selectList(any())).thenReturn( |
| | | Arrays.asList(firstPairShallowLoc), |
| | | Arrays.asList(secondPairShallowLoc)); |
| | | when(locMastService.selectOne(any())).thenReturn(firstPairDeepLoc, secondPairDeepLoc); |
| | | |
| | | FindLocNoAttributeVo attributeVo = new FindLocNoAttributeVo(); |
| | | LocMast firstResult = ReflectionTestUtils.invokeMethod(commonService, "findConfiguredEmptyLocForCrn", |
| | | rowLastno, buildRowLastnoType(), 1, 2, null, attributeVo, false); |
| | | LocMast secondResult = ReflectionTestUtils.invokeMethod(commonService, "findConfiguredEmptyLocForCrn", |
| | | rowLastno, buildRowLastnoType(), 1, 2, null, attributeVo, false); |
| | | |
| | | assertEquals("D-004", firstResult.getLocNo()); |
| | | assertEquals(Integer.valueOf(4), firstResult.getRow1()); |
| | | assertEquals("D-001", secondResult.getLocNo()); |
| | | assertEquals(Integer.valueOf(1), secondResult.getRow1()); |
| | | } |
| | | |
| | | @Test |
| | | void doubleExtension_shouldUseLessLoadedPairFirstWhenBothSidesAreOpen() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionTwoPairProfile(); |
| | | when(basCrnDepthRuleService.resolveProfile(rowLastno, 1, 2)).thenReturn(profile); |
| | | |
| | | when(locMastService.selectCount(any())).thenReturn(2, 2, 0, 0); |
| | | LocMast openShallowLoc = buildLoc("S-003", 3, 1, 1, "O", 1); |
| | | LocMast openDeepLoc = buildLoc("D-004", 4, 1, 1, "O", 1); |
| | | when(locMastService.selectList(any())).thenReturn( |
| | | Collections.<LocMast>emptyList(), |
| | | Collections.<LocMast>emptyList(), |
| | | Arrays.asList(openShallowLoc)); |
| | | when(locMastService.selectOne(any())).thenReturn(openDeepLoc); |
| | | |
| | | FindLocNoAttributeVo attributeVo = buildAttributeVo("PO-003"); |
| | | |
| | | LocMast result = ReflectionTestUtils.invokeMethod(commonService, "findConfiguredEmptyLocForCrn", |
| | | rowLastno, buildRowLastnoType(), 1, 2, null, attributeVo, false); |
| | | |
| | | assertEquals("D-004", result.getLocNo()); |
| | | assertEquals(Integer.valueOf(4), result.getRow1()); |
| | | assertEquals("O", result.getLocSts()); |
| | | } |
| | | |
| | | @Test |
| | | void doubleExtension_shouldFallBackWhenSameStandby1DeepLocHasNoEmptyShallowPartner() { |
| | | RowLastno rowLastno = buildRowLastno(); |
| | | CrnDepthRuleProfile profile = buildDoubleExtensionTwoPairProfile(); |
| | | when(basCrnDepthRuleService.resolveProfile(rowLastno, 1, 2)).thenReturn(profile); |
| | | |
| | | LocMast sameGoodsDeepLoc = buildLoc("D-001", 1, 1, 1, "F", 1); |
| | | LocMast genericShallowLoc = buildLoc("S-002", 2, 2, 1, "O", 1); |
| | | LocMast genericDeepFallbackLoc = buildLoc("D-002", 1, 2, 1, "F", 1); |
| | | LocMast genericShallowLoc = buildLoc("S-003", 3, 1, 1, "O", 1); |
| | | LocMast genericDeepFallbackLoc = buildLoc("D-004", 4, 1, 1, "O", 1); |
| | | LocDetl deepDetl = buildDetl("D-001", "PO-001"); |
| | | |
| | | when(locMastService.selectList(any())).thenReturn(Arrays.asList(sameGoodsDeepLoc), Arrays.asList(genericShallowLoc)); |
| | | when(locMastService.selectList(any())).thenReturn( |
| | | Collections.<LocMast>emptyList(), |
| | | Arrays.asList(sameGoodsDeepLoc), |
| | | Arrays.asList(genericShallowLoc)); |
| | | when(locDetlService.selectList(any())).thenReturn(Arrays.asList(deepDetl)); |
| | | when(locMastService.selectOne(any())).thenReturn(null, null, genericDeepFallbackLoc); |
| | | when(locMastService.selectOne(any())).thenReturn(null, genericDeepFallbackLoc); |
| | | |
| | | LocMast result = ReflectionTestUtils.invokeMethod(commonService, "findConfiguredEmptyLocForCrn", |
| | | rowLastno, buildRowLastnoType(), 1, 2, null, buildAttributeVo("PO-001"), false); |
| | | |
| | | assertEquals("S-002", result.getLocNo()); |
| | | assertEquals(Integer.valueOf(2), result.getRow1()); |
| | | assertEquals("D-004", result.getLocNo()); |
| | | assertEquals(Integer.valueOf(4), result.getRow1()); |
| | | assertEquals("O", result.getLocSts()); |
| | | } |
| | | |
| | |
| | | return profile; |
| | | } |
| | | |
| | | private CrnDepthRuleProfile buildDoubleExtensionTwoPairProfile() { |
| | | CrnDepthRuleProfile profile = new CrnDepthRuleProfile(); |
| | | profile.setLayoutType(2); |
| | | profile.setSearchRows(Arrays.asList(2, 3, 1, 4)); |
| | | profile.setShallowRows(Arrays.asList(2, 3)); |
| | | profile.setDeepRows(Arrays.asList(1, 4)); |
| | | LinkedHashMap<Integer, Integer> shallowToDeep = new LinkedHashMap<Integer, Integer>(); |
| | | shallowToDeep.put(2, 1); |
| | | shallowToDeep.put(3, 4); |
| | | LinkedHashMap<Integer, Integer> deepToShallow = new LinkedHashMap<Integer, Integer>(); |
| | | deepToShallow.put(1, 2); |
| | | deepToShallow.put(4, 3); |
| | | profile.setShallowToDeepRow(shallowToDeep); |
| | | profile.setDeepToShallowRow(deepToShallow); |
| | | return profile; |
| | | } |
| | | |
| | | private CrnDepthRuleProfile buildSingleExtensionProfile() { |
| | | CrnDepthRuleProfile profile = new CrnDepthRuleProfile(); |
| | | profile.setLayoutType(1); |