use of com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand in project elasticsearch-maven-plugin by alexcojocaru.
the class BootstrapClusterStepTest method testExecuteInitCommandPut.
@Test
public void testExecuteInitCommandPut() throws ElasticsearchClientException {
ElasticsearchCommand command = mock(ElasticsearchCommand.class);
when(command.getRequestMethod()).thenReturn(RequestMethod.PUT);
when(command.getJson()).thenReturn("json");
when(command.getRelativeUrl()).thenReturn("index/type/id");
step.executeInitCommand(client, log, command);
verify(client).put("/index/type/id", "json");
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand in project elasticsearch-maven-plugin by alexcojocaru.
the class BootstrapClusterStep method parseJson.
protected void parseJson(ElasticsearchClient client, Log log, Path path) {
try {
String json = new String(Files.readAllBytes(path));
List<Map<String, Object>> commands = new ObjectMapper().readValue(json, new TypeReference<List<Map<String, Object>>>() {
});
commands.forEach(command -> {
log.debug(String.format("Parsing command: %s", command));
ElasticsearchCommand esCommand = parseMapCommand(command);
executeInitCommand(client, log, esCommand);
});
} catch (IOException e) {
throw new ElasticsearchSetupException("Cannot read the init json file", e);
}
}
use of com.github.alexcojocaru.mojo.elasticsearch.v2.client.ElasticsearchCommand in project elasticsearch-maven-plugin by alexcojocaru.
the class BootstrapClusterStep method parseScript.
protected void parseScript(ElasticsearchClient client, Log log, Path path) {
try (Stream<String> stream = Files.lines(path)) {
stream.forEach(command -> {
log.debug(String.format("Parsing command: %s", command));
ElasticsearchCommand esCommand = parseStringCommand(command);
if (esCommand.isSkip() == false) {
executeInitCommand(client, log, esCommand);
}
});
} catch (IOException e) {
throw new ElasticsearchSetupException("Cannot read the init script file", e);
}
}
Aggregations