From 68694b0ffb1018f82e74d503fbb4a635ad89435a Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Tue, 22 Oct 2024 13:39:48 -0400 Subject: [PATCH] Removing `AgentProtocols` --- .../jenkins/support/impl/AgentProtocols.java | 81 ------------------- .../support/impl/AgentProtocolsTest.java | 28 ------- 2 files changed, 109 deletions(-) delete mode 100644 src/main/java/com/cloudbees/jenkins/support/impl/AgentProtocols.java delete mode 100644 src/test/java/com/cloudbees/jenkins/support/impl/AgentProtocolsTest.java diff --git a/src/main/java/com/cloudbees/jenkins/support/impl/AgentProtocols.java b/src/main/java/com/cloudbees/jenkins/support/impl/AgentProtocols.java deleted file mode 100644 index 46e52bf16..000000000 --- a/src/main/java/com/cloudbees/jenkins/support/impl/AgentProtocols.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.cloudbees.jenkins.support.impl; - -import com.cloudbees.jenkins.support.api.Component; -import com.cloudbees.jenkins.support.api.Container; -import com.cloudbees.jenkins.support.api.PrintedContent; -import edu.umd.cs.findbugs.annotations.NonNull; -import hudson.Extension; -import hudson.security.Permission; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.Collections; -import java.util.Set; -import jenkins.AgentProtocol; -import jenkins.model.Jenkins; - -@Extension -public class AgentProtocols extends Component { - - @NonNull - @Override - public Set getRequiredPermissions() { - return Collections.emptySet(); - } - - @NonNull - @Override - public String getDisplayName() { - return "Agent Protocols"; - } - - @Override - public void addContents(@NonNull Container container) { - container.add(new PrintedContent("agent-protocols.md") { - - @Override - protected void printTo(PrintWriter out) throws IOException { - try { - Set agentProtocols = Jenkins.get().getAgentProtocols(); - out.println("Active protocols"); - out.println("================"); - out.println(); - AgentProtocol.all().stream() - .filter(agentProtocol -> - agentProtocol.getName() != null && agentProtocols.contains(agentProtocol.getName())) - .forEach(agentProtocol -> { - out.println(" * `" + agentProtocol.getName() + "`: " + agentProtocol.getDisplayName()); - out.println(" * Deprecated: " + agentProtocol.isDeprecated()); - out.println(" * Required: " + agentProtocol.isRequired()); - out.println(" * Opt In: " + agentProtocol.isOptIn()); - }); - out.println(); - out.println("Inactive protocols"); - out.println("=================="); - out.println(); - AgentProtocol.all().stream() - .filter(agentProtocol -> agentProtocol.getName() != null - && !agentProtocols.contains(agentProtocol.getName())) - .forEach(agentProtocol -> { - out.println(" * `" + agentProtocol.getName() + "`: " + agentProtocol.getDisplayName()); - out.println(" * Deprecated: " + agentProtocol.isDeprecated()); - out.println(" * Required: " + agentProtocol.isRequired()); - out.println(" * Opt In: " + agentProtocol.isOptIn()); - }); - } finally { - out.flush(); - } - } - - @Override - public boolean shouldBeFiltered() { - return false; - } - }); - } - - @NonNull - @Override - public ComponentCategory getCategory() { - return ComponentCategory.AGENT; - } -} diff --git a/src/test/java/com/cloudbees/jenkins/support/impl/AgentProtocolsTest.java b/src/test/java/com/cloudbees/jenkins/support/impl/AgentProtocolsTest.java deleted file mode 100644 index 874db471e..000000000 --- a/src/test/java/com/cloudbees/jenkins/support/impl/AgentProtocolsTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.cloudbees.jenkins.support.impl; - -import static org.hamcrest.CoreMatchers.containsString; - -import com.cloudbees.jenkins.support.SupportTestUtils; -import com.cloudbees.jenkins.support.api.Component; -import hudson.ExtensionList; -import jenkins.AgentProtocol; -import org.hamcrest.MatcherAssert; -import org.junit.Rule; -import org.junit.Test; -import org.jvnet.hudson.test.JenkinsRule; - -public class AgentProtocolsTest { - - @Rule - public JenkinsRule j = new JenkinsRule(); - - @Test - public void testAgentProtocolsContents() { - String itemsContentToString = SupportTestUtils.invokeComponentToString( - ExtensionList.lookup(Component.class).get(AgentProtocols.class)); - AgentProtocol.all().forEach(s -> { - MatcherAssert.assertThat( - itemsContentToString, containsString(" * `" + s.getName() + "`: " + s.getDisplayName())); - }); - } -}