File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\matrix\MatrixConfigurationSorterTest.java.html

1 package hudson.matrix;
2
3 import hudson.model.Item;
4 import hudson.util.FormValidation;
5
6 import org.jvnet.hudson.test.HudsonTestCase;
7 import org.jvnet.hudson.test.TestExtension;
8 import org.kohsuke.stapler.DataBoundConstructor;
9
10 /**
11 * @author Kohsuke Kawaguchi
12 */
13 public class MatrixConfigurationSorterTest extends HudsonTestCase {
14 public void testConfigRoundtrip() throws Exception {
15 MatrixProject p = createMatrixProject();
16 configRoundtrip((Item)p);
17 assertEqualDataBoundBeans(new NoopMatrixConfigurationSorter(),p.getSorter());
18
19 SorterImpl before = new SorterImpl();
20 p.setSorter(before);
21 p.setRunSequentially(true);
22 configRoundtrip((Item)p);
23 Object after = p.getSorter();
24 assertNotSame(before,after);
25 assertSame(before.getClass(),after.getClass());
26 }
27
28 public static class SorterImpl extends MatrixConfigurationSorter {
29 @DataBoundConstructor
30 public SorterImpl() {}
31
32 @Override
33 public void validate(MatrixProject p) throws FormValidation {
34 }
35
36 public int compare(MatrixConfiguration o1, MatrixConfiguration o2) {
37 return o1.getDisplayName().compareTo(o2.getDisplayName());
38 }
39
40 @TestExtension
41 public static class DescriptorImpl extends MatrixConfigurationSorterDescriptor {
42 @Override
43 public String getDisplayName() {
44 return "Test Sorter";
45 }
46 }
47 }
48 }
49