From 222aff37567f0d23e7b547d81d8793bd82694db4 Mon Sep 17 00:00:00 2001 From: Ulli Hafner Date: Tue, 2 Feb 2021 00:26:01 +0100 Subject: [PATCH] Add a test for the print message. --- .../steps/AnalysisStepDescriptorTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/AnalysisStepDescriptorTest.java diff --git a/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/AnalysisStepDescriptorTest.java b/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/AnalysisStepDescriptorTest.java new file mode 100644 index 0000000000..1997f06b61 --- /dev/null +++ b/plugin/src/test/java/io/jenkins/plugins/analysis/core/steps/AnalysisStepDescriptorTest.java @@ -0,0 +1,33 @@ +package io.jenkins.plugins.analysis.core.steps; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import io.jenkins.plugins.analysis.core.steps.ScanForIssuesStep.Descriptor; + +import static org.assertj.core.api.Assertions.*; + +/** + * Tests the class {@link AnalysisStepDescriptor}. + * + * @author Ullrich Hafner + */ +class AnalysisStepDescriptorTest { + @Test + void shouldPrintArgumentsToString() { + Descriptor descriptor = new Descriptor(); + + assertThat(descriptor.argumentsToString(new HashMap<>())).isEqualTo("{}"); + + Map singleton = new HashMap<>(); + singleton.put("key", "value"); + assertThat(descriptor.argumentsToString(singleton)).isEqualTo("value"); + + Map multiple = new HashMap<>(); + multiple.put("key-1", "value-1"); + multiple.put("key-2", "value-2"); + assertThat(descriptor.argumentsToString(multiple)).isEqualTo("{key-1=value-1, key-2=value-2}"); + } +}