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]
}
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");
}
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);
}
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);
}
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;
}
Aggregations