| | |
| | | Clock clock = mock(Clock.class); |
| | | when(clock.instant()).thenReturn(CAPTURED_AT); |
| | | var service = new TestDataReceptionServiceImpl(fixture.mapper, fixture.tests, fixture.simulator, clock); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(true, |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(true, |
| | | List.of(collector("S-01", 10L, "temperature", "25.1", "℃")))); |
| | | when(fixture.mapper.insertRealtimeRecord(any())).thenReturn(1); |
| | | service.captureReceivedData(); |
| | | |
| | | when(clock.instant()).thenReturn(CAPTURED_AT.plusSeconds(5)); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(true, |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(true, |
| | | List.of(collector("S-01", 11L, "temperature", "38", "℃")))); |
| | | service.captureReceivedData(); |
| | | |
| | |
| | | test.getBatteries().get(0).setCollectorChannels(List.of( |
| | | mapping("PRIMARY_TEMPERATURE", "S-01"), mapping("SECONDARY_TEMPERATURE_2", "S-03"), |
| | | mapping("SECONDARY_TEMPERATURE_3", "S-05"))); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(true, List.of( |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(true, List.of( |
| | | collector("S-01", 10L, "temperature", "38", "℃"), |
| | | collector("S-03", 10L, "temperature", "25.3", "℃"), |
| | | collector("S-05", 10L, "temperature", "25.5", "℃")))); |
| | |
| | | { |
| | | Fixture fixture = fixture(); |
| | | when(fixture.simulator.latestCabinet(any(ChannelIdentity.class))).thenReturn(cabinetRecord()); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(true, List.of( |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(true, List.of( |
| | | collector("S-01", 10L, "TEMPERATURE", "25.100", "℃"), |
| | | collector("S-02", 10L, "POSITIVE_POTENTIAL", "1.620", "V"), |
| | | collector("S-03", 10L, "NEGATIVE_POTENTIAL", "1.610", "V"), |
| | |
| | | { |
| | | Fixture fixture = fixture(); |
| | | when(fixture.simulator.latestCabinet(any(ChannelIdentity.class))).thenThrow(new IllegalArgumentException("offline")); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(true, |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(true, |
| | | List.of(collector("S-01", 11L, "TEMPERATURE", "26.2", "℃")))); |
| | | when(fixture.mapper.insertRealtimeRecord(any())).thenReturn(1); |
| | | |
| | |
| | | { |
| | | Fixture fixture = fixture(); |
| | | when(fixture.simulator.latestCabinet(any(ChannelIdentity.class))).thenReturn(cabinetRecord()); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(false, List.of())); |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(false, List.of())); |
| | | when(fixture.mapper.insertRealtimeRecord(any())).thenReturn(1); |
| | | |
| | | fixture.service().captureReceivedData(); |
| | |
| | | { |
| | | Fixture fixture = fixture(); |
| | | when(fixture.simulator.latestCabinet(any(ChannelIdentity.class))).thenReturn(cabinetRecord()); |
| | | when(fixture.simulator.latestCollector("collector-9")).thenReturn(collectorSnapshot(false, List.of())); |
| | | when(fixture.simulator.latestCollector(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.eq("collector-9"))).thenReturn(collectorSnapshot(false, List.of())); |
| | | when(fixture.mapper.selectRealtimeRecordContentHash(eq(1L), eq(4L), any(Date.class))) |
| | | .thenReturn("different-content"); |
| | | |