| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.zy.ai.domain.autotune.AutoTuneRuleSnapshotItem; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasStation; |
| | | import com.zy.asrs.entity.WrkMast; |
| | |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import static org.junit.jupiter.api.Assertions.assertEquals; |
| | |
| | | assertNull(result.get("101")); |
| | | assertEquals(0, result.get("102")); |
| | | assertEquals(3, result.get("103")); |
| | | } |
| | | |
| | | @Test |
| | | void buildRuleSnapshotExposesStepRangeCooldownAndDynamicMaxSource() { |
| | | List<AutoTuneRuleSnapshotItem> result = service.buildRuleSnapshot(); |
| | | |
| | | AutoTuneRuleSnapshotItem stationOutTaskRule = findRule(result, "station", "outTaskLimit"); |
| | | assertEquals(0, stationOutTaskRule.getMinValue()); |
| | | assertNull(stationOutTaskRule.getMaxValue()); |
| | | assertEquals(1, stationOutTaskRule.getMaxStep()); |
| | | assertEquals(10, stationOutTaskRule.getCooldownMinutes()); |
| | | assertEquals(Boolean.TRUE, stationOutTaskRule.getDynamicMaxValue()); |
| | | assertEquals("currentParameterSnapshot.stationOutBufferCapacities[targetId]", |
| | | stationOutTaskRule.getDynamicMaxSource()); |
| | | |
| | | AutoTuneRuleSnapshotItem crnMaxOutRule = findRule(result, "crn", "maxOutTask"); |
| | | assertEquals(3, crnMaxOutRule.getMaxStep()); |
| | | |
| | | AutoTuneRuleSnapshotItem crnMaxInRule = findRule(result, "crn", "maxInTask"); |
| | | assertEquals(1, crnMaxInRule.getMaxStep()); |
| | | } |
| | | |
| | | @Test |
| | |
| | | stationObjModel.setStationId(stationId); |
| | | return stationObjModel; |
| | | } |
| | | |
| | | private AutoTuneRuleSnapshotItem findRule(List<AutoTuneRuleSnapshotItem> rules, |
| | | String targetType, |
| | | String targetKey) { |
| | | for (AutoTuneRuleSnapshotItem rule : rules) { |
| | | if (targetType.equals(rule.getTargetType()) && targetKey.equals(rule.getTargetKey())) { |
| | | return rule; |
| | | } |
| | | } |
| | | throw new AssertionError("rule not found: " + targetType + "/" + targetKey); |
| | | } |
| | | } |