/** * {@inheritDoc} */ @Override public String toString() { return "JmxSensorValueData [jmxSensorDefinitionDataIdent=" + jmxSensorDefinitionDataIdentId + ", value=" + value + ", getId()=" + getId() + ", getPlatformIdent()=" + getPlatformIdent() + ", getSensorTypeIdent()=" + getSensorTypeIdent() + ", getTimeStamp()=" + getTimeStamp() + "]"; }
Root<JmxSensorValueData> sqRoot = sq.from(JmxSensorValueData.class); Predicate platformIdentPredicate = cb.equal(sqRoot.get("platformIdent"), template.getPlatformIdent()); Predicate sensorTypeIdentPredicate = cb.equal(sqRoot.get("sensorTypeIdent"), template.getSensorTypeIdent()); Predicate predicate = cb.and(platformIdentPredicate, sensorTypeIdentPredicate);
@Test public void noJmxIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
if (template.getPlatformIdent() > 0) { query.setPlatformIdent(template.getPlatformIdent());
/** * 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); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(jmxDefinitionDataIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId)));
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId)));
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId)));
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId)));
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(jmxDefinitionDataIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getValueAsDouble()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME, String.valueOf(JMX_ATTR))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId)));