Skip to content

Commit

Permalink
<version>4.75</version>
Browse files Browse the repository at this point in the history
  • Loading branch information
damianszczepanik committed Dec 30, 2023
1 parent 1724096 commit d532276
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ buildPlugin(
useContainerAgent: true,
failFast: false,
platforms: ['linux', 'windows'],
jdkVersions: [11]
jdkVersions: [11, 17]
)
75 changes: 34 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.76</version>
<relativePath />
<version>4.75</version>
</parent>

<groupId>pl.damianszczepanik</groupId>
Expand All @@ -17,7 +17,7 @@
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.387.x</artifactId>
<version>2543.vfb_1a_5fb_9496d</version>
<version>2483.v3b_22f030990a_</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -38,8 +38,6 @@
<slf4jVersion>1.7.30</slf4jVersion>
<asm.version>9.4</asm.version>
<powermock.version>2.0.9</powermock.version>
<!-- releases newer than this do not have Deencapsulation class-->
<jmockit.version>1.34</jmockit.version>

<test.integration.pattern>**/*IT.java</test.integration.pattern>

Expand Down Expand Up @@ -180,82 +178,77 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.2</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>${jmockit.version}</version>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<artifactId>workflow-multibranch</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-multibranch</artifactId>
<groupId>org.powermock</groupId>
<artifactId>powermock-reflect</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
import hudson.model.AbstractItem;
import hudson.model.Job;
import hudson.model.Run;
import mockit.Deencapsulation;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.ConditionBuilder;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.Rule;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.RuleBuilder;
Expand Down Expand Up @@ -73,15 +73,15 @@ public void perform_InitializesRule() throws IOException, InterruptedException {

// given
Rule rule = new Rule(Arrays.asList(new ConditionBuilder.NegativeCondition()), null);
Deencapsulation.setField(rule, "matchedTimes", 1);
Whitebox.setInternalState(rule, "matchedTimes", 1);
BuildHistoryManager discarder = new BuildHistoryManager(Arrays.asList(rule));
Job<?, ?> job = JobBuilder.buildSampleJob();

// when
discarder.perform(job);

// then
int matchedTimes = Deencapsulation.getField(rule, "matchedTimes");
int matchedTimes = Whitebox.getInternalState(rule, "matchedTimes");
assertThat(matchedTimes).isZero();
}

Expand Down Expand Up @@ -160,7 +160,7 @@ public void perform_OnNotContinueAfterMatch_ValidatesOnlyFirstRules() throws IOE
sampleRules = Arrays.asList(new RuleBuilder.TestRule(true), new RuleBuilder.TestRule(true));
RuleConfiguration configuration = new RuleConfiguration();
configuration.setContinueAfterMatch(false);
Deencapsulation.setField(sampleRules.get(0), "configuration", configuration);
Whitebox.setInternalState(sampleRules.get(0), "configuration", configuration);

BuildHistoryManager discarder = new BuildHistoryManager(sampleRules);
Job<?, ?> job = JobBuilder.buildSampleJob();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import java.util.List;

import hudson.model.Run;
import mockit.Deencapsulation;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.actions.Action;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.actions.ActionBuilder;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.conditions.Condition;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void validateConditions_OnNegativeCondition_DoesNotIncrementMatchedTimes(
rule.validateConditions(run);

// then
int matchedTimes = Deencapsulation.getField(rule, "matchedTimes");
int matchedTimes = Whitebox.getInternalState(rule, "matchedTimes");
assertThat(matchedTimes).isZero();
}

Expand Down Expand Up @@ -153,7 +153,7 @@ public void validateConditions_PerformsNTimes() throws IOException, InterruptedE
rule.validateConditions(run);

// then
int matchedTimes = Deencapsulation.getField(rule, "matchedTimes");
int matchedTimes = Whitebox.getInternalState(rule, "matchedTimes");
assertThat(matchedTimes).isOne();

for (Condition condition : rule.getConditions()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import hudson.model.Result;
import hudson.model.Run;
import hudson.security.Permission;
import mockit.Deencapsulation;
import org.apache.commons.lang.StringUtils;
import org.powermock.reflect.Whitebox;

/**
* @author Damian Szczepanik (damianszczepanik@github)
Expand Down Expand Up @@ -82,7 +82,7 @@ public void setPreviousBuild(Run previousBuild) {
}

private void setStartTime(long startTime) {
Deencapsulation.setField(this, "startTime", startTime);
Whitebox.setInternalState(this, "startTime", startTime);
}

@Override
Expand Down

0 comments on commit d532276

Please sign in to comment.