| | |
| | | } |
| | | |
| | | @Test |
| | | void importedStepNamesSupplyDirectionWithoutInventingProtocolTypes() throws Exception |
| | | { |
| | | var discharge = step(1, null, "1", "0.25"); discharge.put("stepName", "恒流放电"); |
| | | var rest = step(2, null, "1", null); rest.put("stepName", "搁置"); |
| | | var charge = step(3, null, "4.2", "0.2"); charge.put("stepName", "恒流充电"); |
| | | var ambiguous = step(4, "pulse", "99", "99"); ambiguous.put("stepName", "恒流充电"); |
| | | when(data.steps(1L)).thenReturn(List.of(discharge, rest, charge, ambiguous)); |
| | | var saved = create(request()); |
| | | var choices = saved.getJSONObject("settings").getJSONObject("curveStepSelections").getJSONObject("1|11|1"); |
| | | assertEquals(List.of(3), choices.getList("charge", Integer.class)); |
| | | assertEquals(List.of(1), choices.getList("discharge", Integer.class)); |
| | | assertEquals(250, saved.getJSONObject("calculatedValues").getBigDecimal("1|11|1|capacity1v").intValueExact()); |
| | | var steps = saved.getJSONArray("items").getJSONObject(0).getJSONObject("chargeSteps").getJSONArray("1"); |
| | | assertEquals("REST", steps.getJSONObject(1).getString("direction")); |
| | | assertEquals("UNKNOWN", steps.getJSONObject(3).getString("direction")); |
| | | } |
| | | |
| | | @Test |
| | | void explicitSourceRefreshKeepsManualValuesAndHistoricalClassification() throws Exception |
| | | { |
| | | var imported = step(1, null, "1", "0.25"); |
| | | when(data.steps(1L)).thenReturn(List.of(imported)); |
| | | var first = create(request()); |
| | | long id = first.getLongValue("id"); |
| | | assertNull(first.getJSONObject("calculatedValues").get("1|11|1|capacity1v")); |
| | | imported.put("stepName", "恒流放电"); |
| | | var refreshed = JSON.parseObject(JSON.toJSONString(service.refresh(id, new CompareReportEditRequest.Refresh(1, "重新读取实际工步"), 1, "操作员"))); |
| | | assertEquals(250, refreshed.getJSONObject("calculatedValues").getBigDecimal("1|11|1|capacity1v").intValueExact()); |
| | | assertEquals("2", refreshed.getJSONObject("settings").getJSONObject("values").getString("1|11|1|manual")); |
| | | var historical = JSON.parseObject(JSON.toJSONString(service.get(id, 1))); |
| | | assertNull(historical.getJSONObject("calculatedValues").get("1|11|1|capacity1v")); |
| | | assertEquals("UNKNOWN", historical.getJSONArray("items").getJSONObject(0).getJSONObject("chargeSteps").getJSONArray("1").getJSONObject(0).getString("direction")); |
| | | } |
| | | |
| | | @Test |
| | | void automaticDirectionSelectionExcludesUnknownAndKeepsAllRealChargeSteps() throws Exception |
| | | { |
| | | when(data.steps(1L)).thenReturn(List.of(step(1,"cc","4.1","0.1"),step(2,"unknown","99","99"),step(3,"cc","4.2","0.2"),step(4,"dc","1","0.25"))); |