@Test public void jmxNotNumeric() { JmxSensorValueData data = new JmxSensorValueData(); data.setValue("string value"); when(influxDBDao.isConnected()).thenReturn(true); doReturn(Collections.singleton(JmxSensorValueData.class)).when(pointBuilder).getDataClasses(); processor = new InfluxProcessor(influxDBDao, Collections.<IPointBuilder<DefaultData>> singletonList(pointBuilder)); processor.process(data, entityManager); verify(influxDBDao).isConnected(); verify(pointBuilder).getDataClasses(); verifyNoMoreInteractions(influxDBDao, pointBuilder); verifyZeroInteractions(entityManager); }
@Test public void jmxNumeric() { JmxSensorValueData data = new JmxSensorValueData(); data.setValue("1"); when(influxDBDao.isConnected()).thenReturn(true); doReturn(Collections.singleton(JmxSensorValueData.class)).when(pointBuilder).getDataClasses(); when(pointBuilder.createBuilders(data)).thenReturn(Collections.singleton(builder)); processor = new InfluxProcessor(influxDBDao, Collections.<IPointBuilder<DefaultData>> singletonList(pointBuilder)); processor.process(data, entityManager); verify(influxDBDao).isConnected(); ArgumentCaptor<Point> pointCaptor = ArgumentCaptor.forClass(Point.class); verify(influxDBDao).insert(pointCaptor.capture()); assertThat(pointCaptor.getValue().lineProtocol(), is(builder.build().lineProtocol())); verifyZeroInteractions(entityManager); }
/** * Copy constructor. Copies all values (except the aggregation values) of the given * {@link JmxSensorValueData} object into the newly created. * * @param origin * object to clone */ public JmxSensorValueData(JmxSensorValueData origin) { setId(origin.getId()); setPlatformIdent(origin.getPlatformIdent()); setTimeStamp(new Timestamp(origin.getTimeStamp().getTime())); setSensorTypeIdent(origin.getSensorTypeIdent()); setJmxSensorDefinitionDataIdentId(origin.jmxSensorDefinitionDataIdentId); setValue(origin.value); }
/** * Constructor. * * @param jmxDefinitionDataIdentId * the id of the related {@link JmxDefinitionDataIdent} of this * {@link JmxSensorValueData} * @param value * the value * @param timestamp * the timestamp when this value was captured * @param platformIdent * the id of the related {@link PlatformIdent} * @param sensorTypeIdent * the id of the related {@link SensorTypeIdent} */ public JmxSensorValueData(long jmxDefinitionDataIdentId, String value, Timestamp timestamp, long platformIdent, long sensorTypeIdent) { setJmxSensorDefinitionDataIdentId(jmxDefinitionDataIdentId); setValue(value); super.setTimeStamp(timestamp); super.setPlatformIdent(platformIdent); super.setSensorTypeIdent(sensorTypeIdent); super.setId(jmxDefinitionDataIdentId); }