Adding a few more tests.
Added unit tests to classes that had no coverage. Added unit tests to classes bump up coverage.
This commit is contained in:
@@ -21,6 +21,7 @@ import org.junit.Test;
|
||||
import org.springframework.cloud.task.batch.listener.support.JobInstanceEvent;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
@@ -36,4 +37,23 @@ public class JobInstanceEventTests {
|
||||
assertEquals(INSTANCE_ID, jobInstanceEvent.getInstanceId());
|
||||
assertEquals(JOB_NAME, jobInstanceEvent.getJobName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyConstructor() {
|
||||
JobInstanceEvent jobInstanceEvent = new JobInstanceEvent();
|
||||
assertNull(jobInstanceEvent.getJobName());
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
public void testEmptyConstructorEmptyId() {
|
||||
JobInstanceEvent jobInstanceEvent = new JobInstanceEvent();
|
||||
jobInstanceEvent.getInstanceId();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString() {
|
||||
JobInstanceEvent jobInstanceEvent = new JobInstanceEvent(INSTANCE_ID, JOB_NAME);
|
||||
assertEquals("JobInstanceEvent: id=1, version=null, Job=[FOOBAR]",
|
||||
jobInstanceEvent.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.task.launcher;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.deployer.spi.local.LocalTaskLauncher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = {TaskLauncherConfiguration.class})
|
||||
public class TaskLaunchConfigurationTests {
|
||||
@Autowired
|
||||
ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testTaskLauncher() {
|
||||
LocalTaskLauncher taskLauncher =
|
||||
context.getBean(LocalTaskLauncher.class);
|
||||
assertNotNull(taskLauncher);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.task.launcher;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Glenn Renfro
|
||||
*/
|
||||
public class TaskLaunchRequestTests {
|
||||
public static final String URI = "http://myURI";
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
List args = new ArrayList<String>();
|
||||
Map map = new HashMap<String,String>();
|
||||
args.add("foo");
|
||||
map.put("bar", "baz");
|
||||
|
||||
TaskLaunchRequest request = new TaskLaunchRequest(URI,
|
||||
Collections.EMPTY_LIST,
|
||||
Collections.EMPTY_MAP,
|
||||
Collections.EMPTY_MAP);
|
||||
TaskLaunchRequest request2 = new TaskLaunchRequest(URI,
|
||||
Collections.EMPTY_LIST,
|
||||
Collections.EMPTY_MAP,
|
||||
Collections.EMPTY_MAP);
|
||||
assertFalse(request.equals(null));
|
||||
assertTrue(request.equals(request));
|
||||
assertTrue(request.equals(request2));
|
||||
TaskLaunchRequest requestDiff = new TaskLaunchRequest("http://oops",
|
||||
Collections.EMPTY_LIST,
|
||||
Collections.EMPTY_MAP,
|
||||
Collections.EMPTY_MAP);
|
||||
assertFalse(request.equals(requestDiff));
|
||||
|
||||
requestDiff = new TaskLaunchRequest(URI,
|
||||
args,
|
||||
Collections.EMPTY_MAP,
|
||||
Collections.EMPTY_MAP);
|
||||
assertFalse(request.equals(requestDiff));
|
||||
|
||||
requestDiff = new TaskLaunchRequest(URI,
|
||||
Collections.EMPTY_LIST,
|
||||
map,
|
||||
Collections.EMPTY_MAP);
|
||||
assertFalse(request.equals(requestDiff));
|
||||
|
||||
requestDiff = new TaskLaunchRequest(URI,
|
||||
Collections.EMPTY_LIST,
|
||||
Collections.EMPTY_MAP,
|
||||
map);
|
||||
assertFalse(request.equals(requestDiff));
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user