use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class MetricCreateOrReplaceTest method testCreateOrReplace.
@Test
public void testCreateOrReplace() throws Exception {
final Metric metric = new Metric("m-create-or-replace");
metric.setDataType(DataType.DECIMAL);
Response response = createOrReplaceMetric(metric.getName(), metric);
assertEquals("Fail to execute createOrReplaceEntityGroup method", OK.getStatusCode(), response.getStatus());
assertTrue("Fail to check metric inserted", metricExist(metric));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class MetricGetTest method testMetricNameContainsSlash.
@Issue("1278")
@Test
public void testMetricNameContainsSlash() throws Exception {
final Metric metric = new Metric("get/metric-2");
createOrReplaceMetricCheck(metric);
Response response = queryMetric(metric.getName());
assertEquals("Fail to execute queryMetric query", OK.getStatusCode(), response.getStatus());
assertTrue("Metrics should be equal", compareJsonString(jacksonMapper.writeValueAsString(metric), response.readEntity(String.class)));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesQueryTest method testVersionedLimitSupport.
@Issue("2970")
@Test
public void testVersionedLimitSupport() throws Exception {
Series series = new Series("e-query-v-l-24", "m-query-v-l-24");
final int limitValue = 2;
Metric versionedMetric = new Metric();
versionedMetric.setName(series.getMetric());
versionedMetric.setVersioned(true);
MetricMethod.createOrReplaceMetric(versionedMetric);
series.addSamples(Sample.ofDateInteger(MIN_STORABLE_DATE, 0), Sample.ofDateInteger(addOneMS(MIN_STORABLE_DATE), 1), Sample.ofDateInteger(addOneMS(addOneMS(MIN_STORABLE_DATE)), 2));
insertSeriesCheck(Collections.singletonList(series));
Map<String, Object> query = new HashMap<>();
query.put("entity", series.getEntity());
query.put("metric", series.getMetric());
query.put("startDate", MIN_QUERYABLE_DATE);
query.put("endDate", MAX_QUERYABLE_DATE);
query.put("versioned", true);
query.put("limit", limitValue);
final Response response = querySeries(query);
JSONArray jsonArray = new JSONArray(response.readEntity(String.class));
final String assertMessage = String.format("Response should contain only %d samples", limitValue);
assertEquals(assertMessage, limitValue, calculateJsonArraySize(((JSONObject) jsonArray.get(0)).getString("data")));
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesQueryWildcardEscapeTest method testEntitySpecialCharEscapeNotFound.
@Issue("4662")
@Test(description = "Test series query for entity name that contains wildcard and nothing were found", dataProvider = "provideSpecialCharacters")
public static void testEntitySpecialCharEscapeNotFound(char c) throws Exception {
String entityName = ENTITY_PREFIX + c + "e2";
String metricName = Mocks.metric();
Series series = new Series(entityName, metricName);
EntityMethod.createOrReplaceEntityCheck(new Entity(entityName));
MetricMethod.createOrReplaceMetricCheck(new Metric(metricName));
SeriesQuery seriesQuery = new SeriesQuery(series);
String actualEntityName = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getEntity();
String expectedEntityName = ENTITY_PREFIX + '\\' + c + "e2";
assertEquals("Wrong result when performing series query with entity that contains wildcard character " + c + " and no series were found", expectedEntityName, actualEntityName);
}
use of com.axibase.tsd.api.model.metric.Metric in project atsd-api-test by axibase.
the class SeriesSearchTest method testAllFields.
@Issue("4404")
@Test(description = "Test all fields returned")
public void testAllFields() {
Entity expectedEntity = EntityMethod.getEntity(resultRecord4.getEntity().getName());
Metric expectedMetric = MetricMethod.getMetric(resultRecord4.getMetric().getName());
SeriesSearchQuery query = new SeriesSearchQuery("sst_22*");
query.addEntityFields("*");
query.addEntityTags("*");
query.addMetricFields("*");
query.addMetricTags("*");
SeriesSearchResult result = SeriesMethod.searchSeries(query);
SeriesSearchResultRecord[] resultRecords = result.getData();
assertTrue(resultRecords != null && resultRecords.length == 1, "Incorrect series count");
SeriesSearchResultRecord resultRecord = resultRecords[0];
Entity resultEntity = resultRecord.getEntity();
Metric resultMetric = resultRecord.getMetric();
assertEquals(resultEntity, expectedEntity);
assertEquals(resultMetric, expectedMetric);
}
Aggregations