use of com.axibase.tsd.api.model.replacementtable.ReplacementTable in project atsd-api-test by axibase.
the class ReplacementTableMethod method replacementTableExist.
public static boolean replacementTableExist(ReplacementTable replacementTable) throws NotCheckedException {
ReplacementTable receivedReplacementTable = findReplacementTable(replacementTable.getName());
if (receivedReplacementTable == null) {
return false;
}
checkReplacementTableName(receivedReplacementTable, replacementTable.getName());
checkReplacementTableContent(receivedReplacementTable, replacementTable.getKeys());
return true;
}
use of com.axibase.tsd.api.model.replacementtable.ReplacementTable in project atsd-api-test by axibase.
the class ReplacementTableMethod method replacementTableExist.
public static boolean replacementTableExist(String replacementTableName) throws NotCheckedException {
ReplacementTable receivedReplacementTable = findReplacementTable(replacementTableName);
if (receivedReplacementTable == null) {
return false;
}
checkReplacementTableName(receivedReplacementTable, replacementTableName);
return true;
}
use of com.axibase.tsd.api.model.replacementtable.ReplacementTable in project atsd-api-test by axibase.
the class ReplacementTableMethod method findReplacementTable.
private static ReplacementTable findReplacementTable(final String replacementTableName) throws NotCheckedException {
String replacementTableNameLowerCase = replacementTableName.replace(" ", "_").toLowerCase();
final Response response = getReplacementTablesResponse(replacementTableNameLowerCase);
if (Response.Status.Family.SUCCESSFUL != Util.responseFamily(response)) {
if (response.getStatus() == NOT_FOUND.getStatusCode()) {
return null;
}
String message = "Fail to execute replacement table query: " + response.getStatusInfo();
log.error(message);
throw new NotCheckedException(message);
}
try {
ReplacementTable replacementTable = response.readEntity(ReplacementTable.class);
return replacementTable;
} catch (ProcessingException err) {
NotCheckedException exception = new NotCheckedException("Could not parse Replacement Table from JSON: " + err.getMessage());
log.error(exception.getMessage());
throw exception;
}
}
use of com.axibase.tsd.api.model.replacementtable.ReplacementTable in project atsd-api-test by axibase.
the class TokenReplacementTableTest method testGetMethod.
@Test(description = "Tests replacement table get endpoint.")
@Issue("6052")
public void testGetMethod() throws Exception {
String replacementTableName = Mocks.replacementTable();
String url = "/replacement-tables/json/" + replacementTableName;
String token = TokenRepository.getToken(username, HttpMethod.GET, url);
ReplacementTable replacementTable = ReplacementTable.of(replacementTableName, SupportedFormat.JSON).addValue("key", "value");
createCheck(replacementTable);
Response response = getReplacementTablesResponse(replacementTableName, token);
assertTrue(compareJsonString(Util.prettyPrint(replacementTable), response.readEntity(String.class)));
}
use of com.axibase.tsd.api.model.replacementtable.ReplacementTable in project atsd-api-test by axibase.
the class TokenReplacementTableTest method testCreateMethod.
@Test(description = "Tests replacement table create or replace endpoint.")
@Issue("6052")
public void testCreateMethod() throws Exception {
String replacementTableName = Mocks.replacementTable();
String url = "/replacement-tables/json/" + replacementTableName;
String token = TokenRepository.getToken(username, HttpMethod.PUT, url);
ReplacementTable replacementTable = ReplacementTable.of(replacementTableName, SupportedFormat.JSON).addValue("key", "value");
createResponse(replacementTable, token);
Checker.check(new ReplacementTableCheck(replacementTable));
}
Aggregations