Search in sources :

Example 41 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class SeriesSearchResultRecordDeserializer method deserialize.

@Override
public SeriesSearchResultRecord deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    SeriesSearchResultRecord result = new SeriesSearchResultRecord();
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    JsonNode metricNameNode = node.get(0);
    String metricName = null;
    if (metricNameNode != null) {
        metricName = metricNameNode.textValue();
    }
    JsonNode metricLabelNode = node.get(1);
    String metricLabel = null;
    if (metricLabelNode != null) {
        metricLabel = metricLabelNode.textValue();
    }
    Metric metric = null;
    JsonNode metricNode = node.get(2);
    if (metricNode != null) {
        metric = mapper.convertValue(metricNode, Metric.class);
    }
    if (metric == null) {
        metric = new Metric();
    }
    metric.setName(metricName);
    metric.setLabel(metricLabel);
    Map<String, String> metricTags = null;
    JsonNode metricTagsNode = node.get(3);
    if (metricTagsNode != null) {
        metricTags = mapper.convertValue(metricTagsNode, Map.class);
    }
    if (metricTags != null && metricTags.size() != 0) {
        metric.setTags(metricTags);
    }
    result.setMetric(metric);
    JsonNode entityNameNode = node.get(4);
    String entityName = null;
    if (entityNameNode != null) {
        entityName = entityNameNode.textValue();
    }
    JsonNode entityLabelNode = node.get(5);
    String entityLabel = null;
    if (entityLabelNode != null) {
        entityLabel = entityLabelNode.textValue();
    }
    Entity entity = null;
    JsonNode entityNode = node.get(6);
    if (entityNode != null) {
        entity = mapper.convertValue(entityNode, Entity.class);
    }
    if (entity == null) {
        entity = new Entity();
    }
    entity.setName(entityName);
    entity.setLabel(entityLabel);
    Map<String, String> entityTags = null;
    JsonNode entityTagsNode = node.get(7);
    if (entityTagsNode != null) {
        entityTags = mapper.convertValue(entityTagsNode, Map.class);
    }
    if (entityTags != null && entityTags.size() != 0) {
        entity.setTags(entityTags);
    }
    result.setEntity(entity);
    Map<String, String> seriesTags = null;
    JsonNode seriesTagsNode = node.get(8);
    if (seriesTagsNode != null) {
        seriesTags = mapper.convertValue(seriesTagsNode, Map.class);
    }
    if (seriesTags != null && seriesTags.size() != 0) {
        result.setSeriesTags(seriesTags);
    }
    Double relevanceScore = null;
    JsonNode relevanceScoreNode = node.get(9);
    if (relevanceScoreNode != null) {
        relevanceScore = relevanceScoreNode.doubleValue();
    }
    result.setRelevanceScore(relevanceScore);
    return result;
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) JsonNode(com.fasterxml.jackson.databind.JsonNode) Metric(com.axibase.tsd.api.model.metric.Metric) Map(java.util.Map)

Example 42 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class CSVUploadTest method testFileWithCRLineBreakAndDST.

@Issue("3591")
@Test
public void testFileWithCRLineBreakAndDST(Method method) throws Exception {
    Entity entity = new Entity("e-cr-dst-parser-ms-2");
    Metric metric = new Metric("m-cr-dst-parser-ms-2");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-cr-dst-parser.csv").toString());
    Response response = binaryCsvUpload(csvPath, CRLF_PARSER, entity.getName());
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 3);
    Sample sample = SeriesMethod.querySeriesAsList(seriesQuery).get(0).getData().get(0);
    Calendar serverCalendar = new GregorianCalendar(TimeZone.getTimeZone(timezone));
    serverCalendar.clear();
    serverCalendar.set(2015, Calendar.NOVEMBER, 24, 6, 17);
    assertEquals("Date failed to save", serverCalendar.getTime(), parseDate(sample.getRawDate()));
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Sample(com.axibase.tsd.api.model.series.Sample) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 43 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class CSVUploadTest method testTimeRangeInISO.

@Issue("2957")
@Test
public void testTimeRangeInISO(Method method) throws Exception {
    Entity entity = new Entity("e-csv-simple-parser-iso-0");
    Metric metric = new Metric("m-csv-simple-parser-iso-0");
    File csvPath = resolvePath(Paths.get(RESOURCE_DIR, "test-time-range-iso.csv").toString());
    Response response = binaryCsvUpload(csvPath, SIMPLE_PARSER_ISO);
    assertEquals("Failed to upload file", OK.getStatusCode(), response.getStatus());
    SeriesQuery seriesQuery = new SeriesQuery(entity.getName(), metric.getName(), MIN_QUERYABLE_DATE, MAX_QUERYABLE_DATE);
    assertSeriesQueryDataSize(seriesQuery, 2);
    List<Series> seriesList = SeriesMethod.querySeriesAsList(seriesQuery);
    Series series = seriesList.get(0);
    assertEquals("Min storable date failed to save", MIN_STORABLE_DATE, series.getData().get(0).getRawDate());
    assertEquals("Incorrect stored value", "12.45", series.getData().get(0).getValue().toString());
    assertEquals("Max storable date failed to save", MAX_STORABLE_DATE, series.getData().get(1).getRawDate());
    assertEquals("Incorrect stored value", "10.8", series.getData().get(1).getValue().toString());
}
Also used : Response(javax.ws.rs.core.Response) Entity(com.axibase.tsd.api.model.entity.Entity) Series(com.axibase.tsd.api.model.series.Series) SeriesQuery(com.axibase.tsd.api.model.series.query.SeriesQuery) Metric(com.axibase.tsd.api.model.metric.Metric) File(java.io.File) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 44 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class EntityCommandTest method testUpdateEntityTagsForExistEntity.

@Issue("3111")
@Test
public void testUpdateEntityTagsForExistEntity() throws Exception {
    Entity storedEntityUpdateTags = new Entity("e-for-test-update-tags");
    storedEntityUpdateTags.addTag(E_TAG_1, E_VAL_1);
    createOrReplaceEntityCheck(storedEntityUpdateTags);
    storedEntityUpdateTags.setTags(Collections.singletonMap(E_TAG_1, E_VAL_1_UPD));
    PlainCommand command = new EntityCommand(storedEntityUpdateTags);
    CommandMethod.send(command);
    assertEntityExisting("Entity tag isn't update for existing entity.", storedEntityUpdateTags);
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) EntityCommand(com.axibase.tsd.api.model.command.EntityCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 45 with Entity

use of com.axibase.tsd.api.model.entity.Entity in project atsd-api-test by axibase.

the class EntityCommandTest method testRawEnabled.

@Issue("3550")
@Test(dataProvider = "correctEnabledProvider")
public void testRawEnabled(String enabled) throws Exception {
    String entityName = entity();
    Entity entity = new Entity(entityName);
    String command = String.format("entity  e:%s b:%s", entityName, enabled);
    CommandMethod.send(command);
    Checker.check(new EntityCheck(entity));
    Entity actualEntity = EntityMethod.getEntity(entityName);
    assertEquals("Failed to set enabled (raw)", enabled.replaceAll("[\\'\\\"]", ""), actualEntity.getEnabled().toString());
}
Also used : Entity(com.axibase.tsd.api.model.entity.Entity) EntityCheck(com.axibase.tsd.api.method.checks.EntityCheck) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

Entity (com.axibase.tsd.api.model.entity.Entity)77 Test (org.testng.annotations.Test)60 Issue (io.qameta.allure.Issue)43 Metric (com.axibase.tsd.api.model.metric.Metric)21 Series (com.axibase.tsd.api.model.series.Series)21 BeforeClass (org.testng.annotations.BeforeClass)15 PropertyQuery (com.axibase.tsd.api.model.property.PropertyQuery)12 EntityCommand (com.axibase.tsd.api.model.command.EntityCommand)9 HashMap (java.util.HashMap)9 Property (com.axibase.tsd.api.model.property.Property)8 SeriesQuery (com.axibase.tsd.api.model.series.query.SeriesQuery)6 EntityCheck (com.axibase.tsd.api.method.checks.EntityCheck)5 Response (javax.ws.rs.core.Response)5 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)4 File (java.io.File)4 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)3 SeriesSearchResultRecord (com.axibase.tsd.api.model.series.search.SeriesSearchResultRecord)3 Sample (com.axibase.tsd.api.model.series.Sample)2 SeriesSearchQuery (com.axibase.tsd.api.model.series.search.SeriesSearchQuery)2 BigDecimal (java.math.BigDecimal)2