Search in sources :

Example 1 with ReplacementTable

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;
}
Also used : ReplacementTable(com.axibase.tsd.api.model.replacementtable.ReplacementTable)

Example 2 with ReplacementTable

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;
}
Also used : ReplacementTable(com.axibase.tsd.api.model.replacementtable.ReplacementTable)

Example 3 with ReplacementTable

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;
    }
}
Also used : Response(javax.ws.rs.core.Response) ReplacementTable(com.axibase.tsd.api.model.replacementtable.ReplacementTable) NotCheckedException(com.axibase.tsd.api.util.NotCheckedException) ProcessingException(javax.ws.rs.ProcessingException)

Example 4 with ReplacementTable

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)));
}
Also used : Response(javax.ws.rs.core.Response) ReplacementTable(com.axibase.tsd.api.model.replacementtable.ReplacementTable) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Example 5 with ReplacementTable

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));
}
Also used : ReplacementTable(com.axibase.tsd.api.model.replacementtable.ReplacementTable) ReplacementTableCheck(com.axibase.tsd.api.method.checks.ReplacementTableCheck) Issue(io.qameta.allure.Issue) Test(org.testng.annotations.Test)

Aggregations

ReplacementTable (com.axibase.tsd.api.model.replacementtable.ReplacementTable)8 Issue (io.qameta.allure.Issue)4 Test (org.testng.annotations.Test)4 ReplacementTableCheck (com.axibase.tsd.api.method.checks.ReplacementTableCheck)3 Response (javax.ws.rs.core.Response)2 DeletionCheck (com.axibase.tsd.api.method.checks.DeletionCheck)1 NotCheckedException (com.axibase.tsd.api.util.NotCheckedException)1 ProcessingException (javax.ws.rs.ProcessingException)1