3 * Copyright (C) 2009-2019 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.es.request;
22 import org.elasticsearch.common.unit.TimeValue;
23 import org.junit.Rule;
24 import org.junit.Test;
25 import org.junit.rules.ExpectedException;
26 import org.sonar.api.utils.log.LogTester;
27 import org.sonar.api.utils.log.LoggerLevel;
28 import org.sonar.server.es.EsTester;
29 import org.sonar.server.es.FakeIndexDefinition;
31 import static org.assertj.core.api.Assertions.assertThat;
33 public class ProxyNodesStatsRequestBuilderTest {
36 public EsTester es = EsTester.createCustom();
39 public LogTester logTester = new LogTester();
42 public ExpectedException thrown = ExpectedException.none();
46 es.client().prepareNodesStats().get();
50 public void to_string() {
51 assertThat(es.client().prepareNodesStats().setNodesIds("node1").toString()).isEqualTo("ES nodes stats request on nodes 'node1'");
52 assertThat(es.client().prepareNodesStats().toString()).isEqualTo("ES nodes stats request");
56 public void trace_logs() {
57 logTester.setLevel(LoggerLevel.TRACE);
59 es.client().prepareNodesStats().get();
61 assertThat(logTester.logs()).hasSize(1);
65 public void get_with_string_timeout_is_not_yet_implemented() {
66 thrown.expect(IllegalStateException.class);
67 thrown.expectMessage("Not yet implemented");
69 es.client().prepareNodesStats(FakeIndexDefinition.INDEX).get("1");
73 public void get_with_time_value_timeout_is_not_yet_implemented() {
74 thrown.expect(IllegalStateException.class);
75 thrown.expectMessage("Not yet implemented");
77 es.client().prepareNodesStats(FakeIndexDefinition.INDEX).get(TimeValue.timeValueMinutes(1));
81 public void execute_should_throw_an_unsupported_operation_exception() {
82 thrown.expect(UnsupportedOperationException.class);
83 thrown.expectMessage("execute() should not be called as it's used for asynchronous");
85 es.client().prepareNodesStats(FakeIndexDefinition.INDEX).execute();