Skip to content

Commit

Permalink
cleanup unused fields and imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl DeBisschop committed Dec 31, 2019
1 parent 1b7f889 commit af7c207
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/bioraft/rundeck/conditional/IfElse.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class IfElse {
/**
* Constructor sets PluginStepContext.
*
* @param ctx
* @param ctx Plugin step context.
*/
public IfElse(PluginStepContext ctx) {
this.ctx = ctx;
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/bioraft/rundeck/conditional/Switch.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Switch {
/**
* Constructor sets PluginStepContext.
*
* @param ctx
* @param ctx Plugin step context
*/
public Switch(PluginStepContext ctx) {
this.ctx = ctx;
Expand Down Expand Up @@ -89,10 +89,10 @@ public boolean switchCase(String group, String name, String cases, String test,
/**
* Adds output to shared context, also elevating to global if requested.
*
* @param elevate
* @param group
* @param name
* @param value
* @param elevate Elevate to global context?
* @param group Variable group.
* @param name Variable name.
* @param value Variable value.
*/
private void addOutput(boolean elevate, String group, String name, String value) {
ctx.getOutputContext().addOutput(group, name, value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import com.dtolabs.rundeck.core.data.DataContext;
import com.dtolabs.rundeck.core.execution.workflow.SharedOutputContext;
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException;
import com.dtolabs.rundeck.plugins.PluginLogger;
Expand All @@ -55,9 +54,6 @@ public class IfElseNodeStepPluginTest {
@Mock
SharedOutputContext sharedOutputContext;

@Mock
DataContext dataContext;

@Before
public void setUp() {
this.plugin = new IfElseNodeStepPlugin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import com.dtolabs.rundeck.core.data.DataContext;
import com.dtolabs.rundeck.core.execution.workflow.SharedOutputContext;
import com.dtolabs.rundeck.core.execution.workflow.steps.StepException;
import com.dtolabs.rundeck.plugins.PluginLogger;
Expand All @@ -55,9 +54,6 @@ public class IfElseStepPluginTest {
@Mock
SharedOutputContext sharedOutputContext;

@Mock
DataContext dataContext;

@Before
public void setUp() {
this.plugin = new IfElseStepPlugin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.mockito.runners.MockitoJUnitRunner;

import com.dtolabs.rundeck.core.common.INodeEntry;
import com.dtolabs.rundeck.core.data.DataContext;
import com.dtolabs.rundeck.core.execution.workflow.SharedOutputContext;
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepException;
import com.dtolabs.rundeck.plugins.PluginLogger;
Expand All @@ -59,9 +58,6 @@ public class SwitchCaseNodeStepPluginTest {
@Mock
SharedOutputContext sharedOutputContext;

@Mock
DataContext dataContext;

@Mock
INodeEntry node;

Expand All @@ -79,7 +75,7 @@ public void runTestOne() throws NodeStepException {
@Test
public void runTestTwo() throws NodeStepException {
Map<String, String> cases = ImmutableMap.<String, String>builder().put("k1", "v1").put("k2", "v2").build();
this.runTest("v2", "k2", cases, "any");
this.runTest("v2", "k2", cases, "thing");
}

@Test
Expand All @@ -92,26 +88,26 @@ public void returnsDefaultOnNoMatch() throws NodeStepException {
public void runTestDefaultIsNull() throws NodeStepException {
Map<String, Object> configuration = new HashMap<>();
configuration.put("defaultValue", null);
this.runTestNoDefault("any", "k3", configuration);
this.runTestNoDefault(configuration);
}

@Test
public void runTestNoDefaultValue() throws NodeStepException {
Map<String, Object> configuration = new HashMap<>();
this.runTestNoDefault("any", "k3", configuration);
this.runTestNoDefault(configuration);
}

private void runTest(String expected, String testValue, Map<String, String> cases, String defaultValue)
throws NodeStepException {
String group = "raft";
String name = "test";
StringBuffer caseString = new StringBuffer();
cases.forEach((k, v) -> caseString.append(k + ":" + v + ";"));
cases.forEach((k, v) -> caseString.append(k).append(":").append(v).append(";"));

Map<String, Object> configuration = new HashMap<>();
configuration.put("group", group);
configuration.put("name", name);
configuration.put("cases", "k1:v1;k2:v2");
configuration.put("cases", caseString);
configuration.put("testValue", testValue);
configuration.put("defaultValue", defaultValue);

Expand All @@ -123,14 +119,14 @@ private void runTest(String expected, String testValue, Map<String, String> case
verify(sharedOutputContext, times(1)).addOutput(eq(group), eq(name), eq(expected));
}

public void runTestNoDefault(String expected, String testValue, Map<String, Object> configuration)
public void runTestNoDefault(Map<String, Object> configuration)
throws NodeStepException {
String group = "raft";
String name = "test";

Map<String, String> cases = ImmutableMap.<String, String>builder().put("k1", "v1").put("k2", "v2").build();
StringBuilder caseString = new StringBuilder();
cases.forEach((k, v) -> caseString.append(k + ":" + v + ";"));
cases.forEach((k, v) -> caseString.append(k).append(":").append(v).append(";"));
configuration.put("cases", caseString.toString());

configuration.put("group", group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import com.dtolabs.rundeck.core.common.INodeEntry;
import com.dtolabs.rundeck.core.data.DataContext;
import com.dtolabs.rundeck.core.execution.workflow.SharedOutputContext;
import com.dtolabs.rundeck.core.execution.workflow.steps.StepException;
import com.dtolabs.rundeck.plugins.PluginLogger;
Expand All @@ -59,12 +57,6 @@ public class SwitchCaseStepPluginTest {
@Mock
SharedOutputContext sharedOutputContext;

@Mock
DataContext dataContext;

@Mock
INodeEntry node;

@Before
public void setUp() {
this.plugin = new SwitchCaseStepPlugin();
Expand All @@ -79,7 +71,7 @@ public void runTestOne() throws StepException {
@Test
public void runTestTwo() throws StepException {
Map<String, String> cases = ImmutableMap.<String, String>builder().put("k1", "v1").put("k2", "v2").build();
this.runTest("v2", "k2", cases, "any");
this.runTest("v2", "k2", cases, "thing");
}

@Test
Expand All @@ -92,26 +84,26 @@ public void returnsDefaultOnNoMatch() throws StepException {
public void runTestFour() throws StepException {
Map<String, Object> configuration = new HashMap<>();
configuration.put("defaultValue", null);
this.runTestNoDefault("any", "k3", configuration);
this.runTestNoDefault(configuration);
}

@Test
public void runTestFive() throws StepException {
Map<String, Object> configuration = new HashMap<>();
this.runTestNoDefault("any", "k3", configuration);
this.runTestNoDefault(configuration);
}

private void runTest(String expected, String testValue, Map<String, String> cases, String defaultValue)
throws StepException {
String group = "raft";
String name = "test";
StringBuffer caseString = new StringBuffer();
cases.forEach((k, v) -> caseString.append(k + ":" + v + ";"));
cases.forEach((k, v) -> caseString.append(k).append(":").append(v).append(";"));

Map<String, Object> configuration = new HashMap<>();
configuration.put("group", group);
configuration.put("name", name);
configuration.put("cases", "k1:v1;k2:v2");
configuration.put("cases", caseString);
configuration.put("testValue", testValue);
configuration.put("defaultValue", defaultValue);

Expand All @@ -123,13 +115,13 @@ private void runTest(String expected, String testValue, Map<String, String> case
verify(sharedOutputContext, times(1)).addOutput(eq(group), eq(name), eq(expected));
}

public void runTestNoDefault(String expected, String testValue, Map<String, Object> configuration) throws StepException {
public void runTestNoDefault(Map<String, Object> configuration) throws StepException {
String group = "raft";
String name = "test";

Map<String, String> cases = ImmutableMap.<String, String>builder().put("k1", "v1").put("k2", "v2").build();
StringBuilder caseString = new StringBuilder();
cases.forEach((k, v) -> caseString.append(k + ":" + v + ";"));
cases.forEach((k, v) -> caseString.append(k).append(":").append(v).append(";"));
configuration.put("cases", caseString.toString());

configuration.put("group", group);
Expand Down

0 comments on commit af7c207

Please sign in to comment.