Search in sources :

Example 1 with ListDataClient

use of com.testvagrant.ekam.dataclients.ListDataClient in project ekam by testvagrant.

the class DataSetsNegativeTests method shouldThrowException.

@Test
@ClearSystemProperty(key = "datasets.env")
@SetSystemProperty(key = "datasets.dir", value = "blahblahblah")
public void shouldThrowException() {
    ListDataClient dataClient = new ListDataClient();
    Exception exception = assertThrows(RuntimeException.class, () -> dataClient.getList("package_managers"));
    String exceptionMessage = exception.getMessage();
    Assertions.assertTrue(exceptionMessage.contains("'package_managers' key not found in data_sets") && exceptionMessage.contains(String.format("Files searched under directory: '%s/%s'", ResourcePaths.TEST_RESOURCES, "blahblahblah")));
}
Also used : ListDataClient(com.testvagrant.ekam.dataclients.ListDataClient) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) Test(org.junit.jupiter.api.Test) ClearSystemProperty(org.junitpioneer.jupiter.ClearSystemProperty)

Example 2 with ListDataClient

use of com.testvagrant.ekam.dataclients.ListDataClient in project ekam by testvagrant.

the class DataSetsNegativeTests method shouldThrowExceptionWhenFileNotPresentForAnEnv.

@Test
@SetSystemProperty(key = "datasets.dir", value = "data_sets")
@SetSystemProperty(key = "datasets.env", value = "staging")
public void shouldThrowExceptionWhenFileNotPresentForAnEnv() {
    ListDataClient dataClient = new ListDataClient();
    Exception exception = assertThrows(RuntimeException.class, () -> dataClient.getList("package_managers"), ".*'package_managers' key not found in data_sets for Env: 'staging'.*");
    String exceptionMessage = exception.getMessage();
    String keyNotFoundInEnv = "'package_managers' key not found in data_sets for Env: 'staging'";
    String searchDirectory = String.format("Files searched under directory: '%s/%s'", ResourcePaths.TEST_RESOURCES, System.getProperty("datasets.dir"));
    Assertions.assertTrue(exceptionMessage.contains(keyNotFoundInEnv) && exceptionMessage.contains(searchDirectory));
}
Also used : ListDataClient(com.testvagrant.ekam.dataclients.ListDataClient) SetSystemProperty(org.junitpioneer.jupiter.SetSystemProperty) Test(org.junit.jupiter.api.Test)

Aggregations

ListDataClient (com.testvagrant.ekam.dataclients.ListDataClient)2 Test (org.junit.jupiter.api.Test)2 SetSystemProperty (org.junitpioneer.jupiter.SetSystemProperty)2 ClearSystemProperty (org.junitpioneer.jupiter.ClearSystemProperty)1