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); }
@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_attributes() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(attribute(section, "Nodes").getLongValue()).isGreaterThan(0); assertThat(attribute(section, "State").getStringValue()).isIn("RED", "YELLOW", "GREEN"); } }
private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) { switch (attribute.getValueCase()) { case BOOLEAN_VALUE: json.prop(attribute.getKey(), attribute.getBooleanValue()); break; case LONG_VALUE: json.prop(attribute.getKey(), attribute.getLongValue()); break; case DOUBLE_VALUE: json.prop(attribute.getKey(), attribute.getDoubleValue()); break; case STRING_VALUE: json.prop(attribute.getKey(), attribute.getStringValue()); break; case VALUE_NOT_SET: json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray(); break; default: throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase()); } }
private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) { switch (attribute.getValueCase()) { case BOOLEAN_VALUE: json.prop(attribute.getKey(), attribute.getBooleanValue()); break; case LONG_VALUE: json.prop(attribute.getKey(), attribute.getLongValue()); break; case DOUBLE_VALUE: json.prop(attribute.getKey(), attribute.getDoubleValue()); break; case STRING_VALUE: json.prop(attribute.getKey(), attribute.getStringValue()); break; case VALUE_NOT_SET: json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray(); break; default: throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase()); } }
@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."); } }