public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, String expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getStringValue()).isEqualTo(expectedValue); }
public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, long expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getLongValue()).isEqualTo(expectedValue); } }
public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, boolean expectedValue) { ProtobufSystemInfo.Attribute value = attribute(section, key); assertThat(value).as(key).isNotNull(); assertThat(value.getBooleanValue()).isEqualTo(expectedValue); }
@Test public void pool_info() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(attribute(section, "Pool Max Connections").getLongValue()).isGreaterThan(0L); assertThat(attribute(section, "Pool Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L); assertThat(attribute(section, "Pool Min Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L); assertThat(attribute(section, "Pool Max Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L); assertThat(attribute(section, "Pool Max Wait (ms)")).isNotNull(); assertThat(attribute(section, "Pool Remove Abandoned")).isNotNull(); assertThat(attribute(section, "Pool Remove Abandoned Timeout (seconds)").getLongValue()).isGreaterThanOrEqualTo(0L); }
@Test public void index_attributes() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); // one index "issues" assertThat(attribute(section, "Index issues - Docs").getLongValue()).isEqualTo(0L); assertThat(attribute(section, "Index issues - Shards").getLongValue()).isGreaterThan(0); assertThat(attribute(section, "Index issues - Store Size").getStringValue()).isNotNull(); }
@Test public void test_setAttribute_with_boolean_parameter() { Section.Builder builder = Section.newBuilder(); SystemInfoUtils.setAttribute(builder, "isNull", (Boolean)null); SystemInfoUtils.setAttribute(builder, "isTrue", true); SystemInfoUtils.setAttribute(builder, "isFalse", false); Section section = builder.build(); assertThat(SystemInfoUtils.attribute(section, "isNull")).isNull(); assertThat(SystemInfoUtils.attribute(section, "isTrue").getBooleanValue()).isTrue(); assertThat(SystemInfoUtils.attribute(section, "isFalse").getBooleanValue()).isFalse(); }
@Test public void no_realm() { when(securityRealmFactory.getRealm()).thenReturn(null); ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); assertThat(attribute(protobuf, "External User Authentication")).isNull(); }
@Test public void no_realm() { when(securityRealmFactory.getRealm()).thenReturn(null); ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); assertThat(attribute(protobuf, "External User Authentication")).isNull(); }
@Test public void return_nb_of_processors() { ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); assertThat(attribute(protobuf, "Processors").getLongValue()).isGreaterThan(0); } }
@Test public void return_nb_of_processors() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(attribute(section, "Processors").getLongValue()).isGreaterThan(0); }
@Test public void db_info() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); SystemInfoTesting.assertThatAttributeIs(section, "Database", "H2"); assertThat(attribute(section, "Database Version").getStringValue()).startsWith("1."); SystemInfoTesting.assertThatAttributeIs(section, "Username", "SONAR"); assertThat(attribute(section, "Driver Version").getStringValue()).startsWith("1."); } }
@Test public void return_dir_paths() { settings.setProperty(PATH_HOME.getKey(), "/home"); settings.setProperty(PATH_DATA.getKey(), "/data"); settings.setProperty(PATH_TEMP.getKey(), "/temp"); settings.setProperty(PATH_LOGS.getKey(), "/logs"); settings.setProperty(PATH_WEB.getKey(), "/web"); ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThatAttributeIs(section, "Home Dir", "/home"); assertThatAttributeIs(section, "Data Dir", "/data"); assertThatAttributeIs(section, "Temp Dir", "/temp"); // logs dir is part of LoggingSection assertThat(attribute(section, "Logs Dir")).isNull(); // for internal usage assertThat(attribute(section, "Web Dir")).isNull(); } }