package org.jenkins.ci.plugins.jenkinslint.check;

import hudson.slaves.DumbSlave;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule;

import static org.junit.Assert.assertTrue;

/**
 * SlaveDescriptionChecker Test Case.
 *
 * @author Victor Martinez
 */
public class SlaveVersionCheckerTestCase {
    private SlaveDescriptionChecker checker = new SlaveDescriptionChecker();

    @Rule public JenkinsRule j = new JenkinsRule();
    @Test public void testDefaultSlave() throws Exception {
        DumbSlave slave = j.createSlave();
        assertTrue(checker.executeCheck(slave));
    }
    @Test public void testEmptySlaveName() throws Exception {
        DumbSlave slave = j.createSlave();
        slave.setNodeName("");
        assertTrue(checker.executeCheck(slave));
    }
    @Test public void testSlaveDescription() throws Exception {
        DumbSlave slave = j.createSlave();
        slave.setNodeName("blablabla");
        assertTrue(checker.executeCheck(slave));
    }
    /**
    @Test public void testControlComment() throws Exception {
        DumbSlave slave = j.createSlave();
        assertFalse(checker.isIgnored(project.getDescription()));
        project.setDescription("#lint:ignore:" + checker.getClass().getSimpleName());
        assertTrue(checker.isIgnored(project.getDescription()));
    }*/
}

@@ -62,24 +62,187 @@
 son.
-slaves.DumbSlave
+model.Node;%0Aimport hudson.model.Slave;%0Aimport hudson.slaves.DumbSlave;%0Aimport hudson.slaves.JNLPLauncher;%0Aimport hudson.slaves.NodeProperty;%0Aimport hudson.slaves.RetentionStrategy
 ;%0Aim
@@ -328,16 +328,91 @@
 sRule;%0A%0A
+import java.util.Collections;%0A%0Aimport static org.junit.Assert.assertFalse;%0A
 import s
@@ -455,32 +455,28 @@
 /**%0A * Slave
-Descript
+Vers
 ionChecker T
@@ -575,32 +575,28 @@
 rivate Slave
-Descript
+Vers
 ionChecker c
@@ -613,24 +613,20 @@
 ew Slave
-Descript
+Vers
 ionCheck
@@ -744,36 +744,32 @@
 ption %7B%0A        
-Dumb
 Slave slave = j.
@@ -758,34 +758,32 @@
   Slave slave = 
-j.
 createSlave();%0A 
@@ -770,32 +770,49 @@
 e = createSlave(
+%22default%22, %22%22, %22%22
 );%0A        asser
@@ -804,35 +804,36 @@
 ;%0A        assert
-Tru
+Fals
 e(checker.execut
@@ -884,22 +884,22 @@
 test
-EmptySlaveName
+ControlComment
 () t
@@ -916,36 +916,32 @@
 ption %7B%0A        
-Dumb
 Slave slave = j.
@@ -930,34 +930,32 @@
   Slave slave = 
-j.
 createSlave();%0A 
@@ -954,37 +954,23 @@
 ave(
-);%0A        slave.setNodeName(
+%22default%22, %22%22, 
 %22%22);
@@ -976,35 +976,36 @@
 ;%0A        assert
-Tru
+Fals
 e(checker.execut
@@ -1002,117 +1002,55 @@
 ker.
-executeCheck(slave));%0A    %7D%0A    @Test public void testSlaveDescription() throws Exception %7B%0A        DumbSlave
+isIgnored(slave.getNodeDescription()));%0A       
  sla
@@ -1046,34 +1046,32 @@
         slave = 
-j.
 createSlave();%0A 
@@ -1070,204 +1070,170 @@
 ave(
-);%0A        slave.setNodeName(%22blablabla%22);%0A        assertTrue(checker.executeCheck(slave));%0A    %7D%0A    /**%0A    @Test public void testControlComment() throws Exception %7B
+%22default%22, %22#lint:ignore:%22 + checker.getClass().getSimpleName(), %22%22);%0A        assertTrue(checker.isIgnored(slave.getNodeDescription()));
 %0A    
+%7D%0A%0A
     
-DumbSlave s
+private S
 lave 
-= j.
 crea
@@ -1244,224 +1244,248 @@
 ave(
-);%0A        assertFalse(checker.isIgnored(project.getDescription()));%0A        project.setDescription(%22#lint:ignore:%22 + checker.getClass().getSimpleName());%0A        assertTrue(checker.isIgnored(project.getDescription()
+String name, String description, String label) throws Exception %7B%0A        return new DumbSlave(name, description, %22/wherever%22, %221%22, Node.Mode.NORMAL, label, new JNLPLauncher(), RetentionStrategy.NOOP, Collections.%3CNodeProperty%3C?%3E%3EemptyList(
 ));%0A
@@ -1489,13 +1489,11 @@
 );%0A    %7D
-*/
 %0A%7D%0A

Test cases for slave version check