public static List<Section> order(Collection<Section> sections, String... orderedNames) { Map<String, Section> alphabeticalOrderedMap = new TreeMap<>(); sections.forEach(section -> alphabeticalOrderedMap.put(section.getName(), section)); List<Section> result = new ArrayList<>(sections.size()); stream(orderedNames).forEach(name -> { Section section = alphabeticalOrderedMap.remove(name); if (section != null) { result.add(section); } }); result.addAll(alphabeticalOrderedMap.values()); return result; } }
@Test public void section_name_depends_on_runtime_side() { when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.COMPUTE_ENGINE); assertThat(underTest.toProtobuf().getName()).isEqualTo("Compute Engine Database Connection"); when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.SERVER ); assertThat(underTest.toProtobuf().getName()).isEqualTo("Web Database Connection"); } }
@Test public void export_system_info() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo("Compute Engine Tasks"); assertThat(section.getAttributesCount()).isEqualTo(8); }
private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) { json.name(section.getName()); json.beginObject(); for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) { writeAttribute(attribute, json); } json.endObject(); }
@Test public void name() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Plugins"); }
@Test public void name() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Search Indexes"); }
@Test public void name_is_not_empty() { assertThat(underTest.toProtobuf().getName()).isEqualTo("System"); }
@Test public void name() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Search State"); }
@Test public void test_name() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Search State"); }
@Test public void test_section_name() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo("System"); }
@Test public void return_logging_attributes_of_compute_engine() { when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.COMPUTE_ENGINE); ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo("Compute Engine Logging"); assertThatAttributeIs(section, "Logs Dir", logDir.getAbsolutePath()); assertThatAttributeIs(section, "Logs Level", "DEBUG"); }
@Test public void export_system_info() { ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo("Compute Engine Database Connection"); assertThat(section.getAttributesCount()).isEqualTo(9); assertThat(section.getAttributes(0).getKey()).isEqualTo("Pool Initial Size"); assertThat(section.getAttributes(0).getLongValue()).isGreaterThanOrEqualTo(0); }
@Test public void name_is_not_empty() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Web JVM Properties"); }
private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) { json.name(section.getName()); json.beginObject(); for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) { writeAttribute(attribute, json); } json.endObject(); }
@Test public void test_monitor_name() { assertThat(underTest.toProtobuf().getName()).isEqualTo("Settings"); } }
@Test public void serves_data_from_SystemInfoSections() throws Exception { NanoHTTPD.Response response = underTest.serve(createHttpSession(GET)); assertThat(response.getStatus()).isEqualTo(OK); ProtobufSystemInfo.SystemInfo systemInfo = ProtobufSystemInfo.SystemInfo.parseFrom(response.getData()); assertThat(systemInfo.getSectionsCount()).isEqualTo(2); assertThat(systemInfo.getSections(0).getName()).isEqualTo("state1"); assertThat(systemInfo.getSections(1).getName()).isEqualTo("state2"); }
@Test public void return_logging_attributes_of_web_server() { when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.SERVER); ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo("Web Logging"); assertThatAttributeIs(section, "Logs Dir", logDir.getAbsolutePath()); assertThatAttributeIs(section, "Logs Level", "DEBUG"); } }
@Test public void toSystemInfoSection() { JvmStateSection underTest = new JvmStateSection(PROCESS_NAME); ProtobufSystemInfo.Section section = underTest.toProtobuf(); assertThat(section.getName()).isEqualTo(PROCESS_NAME); assertThat(section.getAttributesCount()).isGreaterThan(0); assertThat(section.getAttributesList()).extracting("key") .contains( "Max Memory (MB)", "Free Memory (MB)", "Heap Max (MB)", "System Load Average", "Threads"); }