Skip to content

Commit

Permalink
Fix Broken Test Cases for InputFilterList Implementation
Browse files Browse the repository at this point in the history
    - Modified test cases that were failing due to the introduction of InputFilterList.
    - Ensured test cases reflect the updated behavior and functionality.
    - Verified all tests pass to maintain code integrity and functionality.

Related to PR #657
  • Loading branch information
LakeLab authored and MCMicS committed Dec 23, 2024
1 parent d9c3bd3 commit 94be7eb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.codinjutsu.tools.jenkins.view.parameter;

import com.intellij.openapi.ui.ComboBox;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.ui.components.JBTextField;
import org.codinjutsu.tools.jenkins.model.BuildInJobParameter;
import org.codinjutsu.tools.jenkins.model.JobParameter;
import org.codinjutsu.tools.jenkins.model.JobParameterType;
Expand All @@ -10,7 +10,7 @@

import javax.swing.*;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

public class BuiltInJobParameterRendererTest implements JobParameterTest {

Expand Down Expand Up @@ -49,7 +49,7 @@ public void isForJobParameterForWrongBuiltInClass() {
public void render() {
final JobParameter jobParameter = createJobParameter(BuildInJobParameter.ChoiceParameterDefinition);
JobParameterComponent<?> jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(JBTextField.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameterComponent = jobParameterRenderer.render(createJobParameter(BuildInJobParameter.BooleanParameterDefinition),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package org.codinjutsu.tools.jenkins.view.parameter;

import com.intellij.openapi.ui.ComboBox;
import org.assertj.core.util.Lists;
import org.codinjutsu.tools.jenkins.logic.RequestManager;
import org.codinjutsu.tools.jenkins.model.BuildInJobParameter;
import org.codinjutsu.tools.jenkins.model.JobParameter;
import org.codinjutsu.tools.jenkins.model.JobParameterType;
import org.codinjutsu.tools.jenkins.view.inputfilter.InputFilterList;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import javax.swing.*;
import java.util.Collections;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

public class GitParameterRendererTest implements JobParameterTest {
private final GitParameterRenderer jobParameterRenderer = new GitParameterRenderer();
Expand Down Expand Up @@ -70,32 +70,32 @@ public void loadFromRequestManager() {
.thenReturn(Lists.newArrayList("First", "Second"));
JobParameter jobParameter = createJobParameter(GitParameterRenderer.PT_TAG);
JobParameterComponent<?> jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(GitParameterRenderer.PT_BRANCH);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(GitParameterRenderer.PT_BRANCH_TAG);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(GitParameterRenderer.PT_REVISION);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(GitParameterRenderer.PT_PULL_REQUEST);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(GitParameterRenderer.GIT_PARAMETER_DEFINITION);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameterComponent = jobParameterRenderer.render(createJobParameter(BuildInJobParameter.ChoiceParameterDefinition),
Expand All @@ -104,36 +104,36 @@ public void loadFromRequestManager() {
}

@Test
public void renderAsComboBox() {
public void renderAsInputFilterList() {
JobParameter jobParameter = createJobParameterChoices(GitParameterRenderer.PT_TAG, "master", "tag/v0.13.6");
JobParameterComponent<?> jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(GitParameterRenderer.PT_BRANCH, "master", "bug/225");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(GitParameterRenderer.PT_BRANCH_TAG, "master", "tag/v0.13.6");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(GitParameterRenderer.PT_REVISION,
"abcf12345 2020-04-14 21:36 user <user@users.noreply.github.com> sample Revision");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(GitParameterRenderer.PT_PULL_REQUEST, "master", "pr/226");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(GitParameterRenderer.GIT_PARAMETER_DEFINITION, "master", "pr/226");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameterComponent = jobParameterRenderer.render(createJobParameter(BuildInJobParameter.ChoiceParameterDefinition),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.codinjutsu.tools.jenkins.view.parameter;

import com.intellij.openapi.ui.ComboBox;
import org.assertj.core.util.Lists;
import org.codinjutsu.tools.jenkins.logic.RequestManager;
import org.codinjutsu.tools.jenkins.model.BuildInJobParameter;
import org.codinjutsu.tools.jenkins.model.JobParameter;
import org.codinjutsu.tools.jenkins.view.inputfilter.InputFilterList;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import javax.swing.*;
import java.util.Collections;

import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.api.Assertions.assertThat;

public class ListGitBranchesParameterRendererTest implements JobParameterTest {

Expand Down Expand Up @@ -51,20 +51,20 @@ public void renderAsInputField() {
}

@Test
public void renderAsComboBox() {
public void renderAsInputFilterList() {
JobParameter jobParameter = createJobParameterChoices(ListGitBranchesParameterRenderer.PT_TAG, "master", "tag/v0.13.6");
JobParameterComponent<?> jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(ListGitBranchesParameterRenderer.PT_BRANCH, "master", "bug/225");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameter = createJobParameterChoices(ListGitBranchesParameterRenderer.PT_BRANCH_TAG, "master", "tag/v0.13.6");
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter()).isEqualTo(jobParameter);

jobParameterComponent = jobParameterRenderer.render(createJobParameter(BuildInJobParameter.ChoiceParameterDefinition),
Expand All @@ -78,17 +78,17 @@ public void loadFromRequestManager() {
.thenReturn(Lists.newArrayList("First", "Second"));
JobParameter jobParameter = createJobParameter(ListGitBranchesParameterRenderer.PT_TAG);
JobParameterComponent<?> jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(ListGitBranchesParameterRenderer.PT_BRANCH);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameter = createJobParameter(ListGitBranchesParameterRenderer.PT_BRANCH_TAG);
jobParameterComponent = jobParameterRenderer.render(jobParameter, PROJECT_JOB);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(ComboBox.class);
assertThat(jobParameterComponent.getViewElement()).isInstanceOf(InputFilterList.class);
assertThat(jobParameterComponent.getJobParameter().getChoices()).contains("First", "Second");

jobParameterComponent = jobParameterRenderer.render(createJobParameter(BuildInJobParameter.ChoiceParameterDefinition),
Expand Down

0 comments on commit 94be7eb

Please sign in to comment.