Search in sources :

Example 6 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class AppendFieldTest method testAppendDuplicates.

@Issue("3796")
@Test
public void testAppendDuplicates() throws Exception {
    final String entityName = entity();
    final String metricName = metric();
    String[] dataWithDuplicates = { "a", "a", "b", "a", "b", "c", "b", "0.1", "word1 word2", "0", "word1", "0.1" };
    Series series = new Series(entityName, metricName);
    series.addSamples(Sample.ofDateText(ISO_TIME, "a;\nb;\nc;\n0.1;\nword1 word2;\n0;\nword1"));
    List<PlainCommand> commandList = new ArrayList<>();
    for (int i = 0; i < dataWithDuplicates.length; i++) {
        SeriesCommand seriesCommand = new SeriesCommand(singletonMap(metricName, dataWithDuplicates[i]), null, entityName, null, null, null, ISO_TIME, true);
        if (i == 0) {
            seriesCommand.setAppend(false);
        }
        commandList.add(seriesCommand);
    }
    CommandMethod.send(commandList);
    assertTextDataEquals(series, "Append with erase doesn't work");
// Append with erase doesn't work, expected result was
// a;
// b;
// c;
// 0.1;
// word1 word2;
// 0;
// word1
// but actual result is:
// [a;
// b;
// c;
// word1 word2;
// 0;
// word1;
// 0.1]
}
Also used : Series(com.axibase.tsd.api.model.series.Series) PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) ArrayList(java.util.ArrayList) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) CommandMethodTest(com.axibase.tsd.api.extended.CommandMethodTest)

Example 7 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class AppendFieldTest method testAppendWithErase.

@Issue("3796")
@Test
public void testAppendWithErase() throws Exception {
    final String entityName = entity();
    final String metricAppendWithErase = metric();
    String[] dataEraseFirst = { "a", "b", "c" };
    String[] dataEraseSecond = { "d", "e", "f", "g" };
    Series series = new Series(entityName, metricAppendWithErase);
    series.addSamples(Sample.ofDateText(ISO_TIME, "d;\ne;\nf;\ng"));
    List<PlainCommand> commandList = new ArrayList<>();
    for (int i = 0; i < dataEraseFirst.length; i++) {
        SeriesCommand seriesCommand = new SeriesCommand(singletonMap(metricAppendWithErase, dataEraseFirst[i]), null, entityName, null, null, null, ISO_TIME, true);
        if (i == 0) {
            seriesCommand.setAppend(false);
        }
        commandList.add(seriesCommand);
    }
    for (int i = 0; i < dataEraseSecond.length; i++) {
        SeriesCommand seriesCommand = new SeriesCommand(singletonMap(metricAppendWithErase, dataEraseSecond[i]), null, entityName, null, null, null, ISO_TIME, true);
        if (i == 0) {
            seriesCommand.setAppend(false);
        }
        commandList.add(seriesCommand);
    }
    CommandMethod.send(commandList);
    assertTextDataEquals(series, "Append with erase doesn't work");
}
Also used : Series(com.axibase.tsd.api.model.series.Series) PlainCommand(com.axibase.tsd.api.model.command.PlainCommand) ArrayList(java.util.ArrayList) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test) CommandMethodTest(com.axibase.tsd.api.extended.CommandMethodTest)

Example 8 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class DQuoteCharEscapeTest method testEntity.

@Issue("2854")
@Test
public void testEntity() throws Exception {
    Series series = new Series("series-command-test\"\"-e1", "series-command-test-m1");
    Sample sample = Sample.ofDateInteger(Mocks.ISO_TIME, 1);
    series.addSamples(sample);
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(sample.getRawDate());
    seriesCommand.setEntityName(series.getEntity());
    seriesCommand.setValues(Collections.singletonMap(series.getMetric(), sample.getValue().toString()));
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 9 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class EqualCharEscapeTest method testMetric.

@Issue("2854")
@Test
public void testMetric() throws Exception {
    Series series = new Series("series-command-test-e4", "series-command-test=-m4");
    Sample sample = Sample.ofJavaDateInteger(TestUtil.getCurrentDate(), 1);
    series.addSamples(sample);
    SeriesCommand seriesCommand = new SeriesCommand();
    seriesCommand.setTimeISO(sample.getRawDate());
    seriesCommand.setEntityName(series.getEntity());
    seriesCommand.setValues(Collections.singletonMap(series.getMetric(), sample.getValue().toString()));
    CommandMethod.send(seriesCommand);
    assertSeriesExisting(series);
}
Also used : Series(com.axibase.tsd.api.model.series.Series) Sample(com.axibase.tsd.api.model.series.Sample) SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) Issue(io.qameta.allure.Issue) SeriesTest(com.axibase.tsd.api.method.series.SeriesTest) Test(org.testng.annotations.Test)

Example 10 with SeriesCommand

use of com.axibase.tsd.api.model.command.SeriesCommand in project atsd-api-test by axibase.

the class Series method toCommands.

public List<SeriesCommand> toCommands() {
    if (type == SeriesType.FORECAST) {
        throw new IllegalArgumentException("Cannot convert FORECAST series to commands");
    }
    List<SeriesCommand> result = new ArrayList<>();
    for (Sample s : data) {
        SeriesCommand seriesCommand = new SeriesCommand();
        seriesCommand.setEntityName(entity);
        BigDecimal value = s.getValue();
        if (value != null) {
            seriesCommand.setValues(Collections.singletonMap(metric, value.toPlainString()));
        }
        seriesCommand.setTexts(Collections.singletonMap(metric, s.getText()));
        seriesCommand.setTags(new HashMap<>(tags));
        seriesCommand.setTimeISO(s.getRawDate());
        seriesCommand.setTimeMills(s.getUnixTime());
        result.add(seriesCommand);
    }
    return result;
}
Also used : SeriesCommand(com.axibase.tsd.api.model.command.SeriesCommand) BigDecimal(java.math.BigDecimal)

Aggregations

SeriesCommand (com.axibase.tsd.api.model.command.SeriesCommand)18 Series (com.axibase.tsd.api.model.series.Series)16 Issue (io.qameta.allure.Issue)16 Test (org.testng.annotations.Test)16 Sample (com.axibase.tsd.api.model.series.Sample)8 SeriesTest (com.axibase.tsd.api.method.series.SeriesTest)6 CommandMethodTest (com.axibase.tsd.api.extended.CommandMethodTest)5 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)5 ArrayList (java.util.ArrayList)4 BigDecimal (java.math.BigDecimal)2 SqlTest (com.axibase.tsd.api.method.sql.SqlTest)1 CommandSendingResult (com.axibase.tsd.api.model.extended.CommandSendingResult)1 BeforeClass (org.testng.annotations.BeforeClass)1