Skip to content

Commit

Permalink
Use JenkinsConfiguredWithCodeRule instead of RoundTripAbstractTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dohbedoh committed Jun 21, 2023
1 parent ff16919 commit cea7b6d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/test/java/com/cloudbees/jenkins/support/CasCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@

import com.cloudbees.jenkins.support.config.SupportAutomatedBundleConfiguration;
import com.cloudbees.jenkins.support.filter.ContentFilters;
import io.jenkins.plugins.casc.misc.RoundTripAbstractTest;
import org.jvnet.hudson.test.RestartableJenkinsRule;
import io.jenkins.plugins.casc.misc.ConfiguredWithCode;
import io.jenkins.plugins.casc.misc.JenkinsConfiguredWithCodeRule;
import org.junit.Rule;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder;
import static org.junit.Assert.assertTrue;

public class CasCTest extends RoundTripAbstractTest {
public class CasCTest {

@Override
protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenkinsRule, String s) {
assertTrue("JCasC should have configured support core to anonymize contents, but it didn't",
@Rule
public JenkinsConfiguredWithCodeRule r = new JenkinsConfiguredWithCodeRule();

@Test
@ConfiguredWithCode("configuration-as-code.yaml")
public void assertConfiguredAsExpected() {
assertTrue("JCasC should have configured support core to anonymize contents, but it didn't",
ContentFilters.get().isEnabled());
assertTrue("JCasC should have configured support period bundle generation enabled, but it didn't",
assertTrue("JCasC should have configured support period bundle generation enabled, but it didn't",
SupportAutomatedBundleConfiguration.get().isEnabled());
assertThat("JCasC should have configured support period bundle generation period, but it didn't",
SupportAutomatedBundleConfiguration.get().getPeriod(),
is(2));
assertThat("JCasC should have configured support period bundle generation period, but it didn't",
SupportAutomatedBundleConfiguration.get().getComponentIds(),
containsInAnyOrder(
"AboutBrowser",
"AboutBrowser",
"AboutJenkins",
"AboutUser",
"AdministrativeMonitors",
Expand Down Expand Up @@ -58,8 +64,4 @@ protected void assertConfiguredAsExpected(RestartableJenkinsRule restartableJenk
));
}

@Override
protected String stringInLogExpected() {
return ".enabled = true";
}
}

0 comments on commit cea7b6d

Please sign in to comment.