From 7a8b5636cc4ee4fd5083dce893a1c4ad7fffab9c Mon Sep 17 00:00:00 2001 From: Sweidan Omar Date: Fri, 10 Dec 2021 10:24:13 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C32547 --- .../user/jobengine/server/JobRuntimeTest.java | 77 +++++++++---------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/server/user.jobengine.osgi.server/test/user/jobengine/server/JobRuntimeTest.java b/server/user.jobengine.osgi.server/test/user/jobengine/server/JobRuntimeTest.java index b0de9df7..d6190b56 100644 --- a/server/user.jobengine.osgi.server/test/user/jobengine/server/JobRuntimeTest.java +++ b/server/user.jobengine.osgi.server/test/user/jobengine/server/JobRuntimeTest.java @@ -25,7 +25,7 @@ public class JobRuntimeTest { @Before public void setup() { program = new Program(); - sut = new JobRuntime(null, program); + sut = new JobRuntime(null, program); } @Test @@ -35,11 +35,11 @@ public class JobRuntimeTest { assertEquals(JobStatus.RUNABLE, sut.getStatus()); assertTrue(sut.getProgram() != null); } - + @Test(expected = NullPointerException.class) public void testConstructor_NullProgram() throws Exception { new JobRuntime(null, null); - } + } @Test public void testHasNextInstruction() throws Exception { @@ -53,40 +53,40 @@ public class JobRuntimeTest { sut.getNextInstruction(); assertFalse(sut.hasNextInstruction()); - } - + } + @Test public void testGetNextInstruction() throws Exception { // Fixture final IInstruction expected = new Instruction(); - + program.addInstruction(expected); - + // Exercise IInstruction instruction = sut.getNextInstruction(); // Verify - assertEquals(expected, instruction); - assertFalse(sut.hasNextInstruction()); + assertEquals(expected, instruction); + assertFalse(sut.hasNextInstruction()); } - + @Test(expected = NoSuchElementException.class) public void testExecuteNextInstruction_NoMoreSteps() throws Exception { // Exercise sut.getNextInstruction(); - } + } @Test(expected = NoSuchElementException.class) public void testGetNextInstruction_NoMoreSteps() throws Exception { // Exercise sut.getNextInstruction(); - } + } @Test(expected = NoSuchElementException.class) public void testGetNextInstruction_NullParameter() throws Exception { // Exercise sut.getNextInstruction(); - } + } @Test public void testGetCurrentInstruction() throws Exception { @@ -95,18 +95,17 @@ public class JobRuntimeTest { final IInstruction instruction2 = new Instruction(); program.addInstruction(instruction1); program.addInstruction(instruction2); - + // Exercise, Verify assertEquals(instruction1, sut.getCurrentInstruction()); sut.getNextInstruction(); assertEquals(instruction2, sut.getCurrentInstruction()); } - @Test(expected = EmptyStackException.class) public void testPop_Empty() throws Exception { // Exercise - sut.popFromStack(); + sut.popFromStack(); } @Test @@ -119,13 +118,13 @@ public class JobRuntimeTest { sut.getNextInstruction(); sut.decrementInstructionPointer(); assertTrue(sut.hasNextInstruction()); - } + } @Test(expected = IllegalStateException.class) public void testIncrementInstructionPointer_AlreadyOnFirst() throws Exception { // Verify sut.decrementInstructionPointer(); - } + } @Test public void testSaveStack() throws Exception { @@ -140,7 +139,7 @@ public class JobRuntimeTest { // Verify assertEquals(value, sut.popFromStack()); - } + } @Test public void testSaveStatus() throws Exception { @@ -154,7 +153,7 @@ public class JobRuntimeTest { // Verify assertEquals(expected, sut.getSavedStatus()); - } + } @Test public void testArrangeStackInstruction() throws Exception { @@ -171,10 +170,10 @@ public class JobRuntimeTest { sut.pushToStack(value1); sut.pushToStack(value2); sut.pushToStack(value3); - + // Exercise sut.arrangeStack(); - + // Verify assertEquals(value1, sut.popFromStack()); assertEquals(var1, sut.popFromStack()); @@ -196,10 +195,10 @@ public class JobRuntimeTest { sut.pushToStack(value2); sut.pushToStack(value3); sut.pushToStack(3); - + // Exercise sut.swapStack(); - + // Verify assertEquals(3, sut.popFromStack()); assertEquals(value1, sut.popFromStack()); @@ -245,22 +244,22 @@ public class JobRuntimeTest { // Fixture final String name = "var1"; final Class type = String.class; - + // Exercise sut.addVariable(name, type); sut.addVariable(name, type); } - + @Test public void testGetVariable() throws Exception { // Fixture final String name = "var1"; final Class type = String.class; sut.addVariable(name, type); - + // Exercise Object result = sut.getVariable(name); - + // Verify assertEquals(type, result); } @@ -268,13 +267,13 @@ public class JobRuntimeTest { @Test(expected = RuntimeException.class) public void testGetVariable_WrongName() throws Exception { // Exercise - sut.getVariable(""); + sut.getVariable(""); } @Test(expected = NullPointerException.class) public void testGetVariable_NullName() throws Exception { // Exercise - sut.getVariable(null); + sut.getVariable(null); } @Test @@ -284,10 +283,10 @@ public class JobRuntimeTest { final Class type = String.class; final String value = "value1"; sut.addVariable(name, type); - + // Exercise sut.setVariable(name, value); - + // Verify assertEquals(value, sut.getVariable(name)); } @@ -308,13 +307,13 @@ public class JobRuntimeTest { @Test(expected = RuntimeException.class) public void testSetVariable_WrongName() throws Exception { // Exercise - sut.setVariable("", null); + sut.setVariable("", null); } @Test(expected = NullPointerException.class) public void testSetVariable_NullName() throws Exception { // Exercise - sut.setVariable(null, null); + sut.setVariable(null, null); } @Test @@ -325,10 +324,10 @@ public class JobRuntimeTest { final Map parameters = new LinkedHashMap(); parameters.put(name, value); sut.setParameters(parameters); - + // Exercise Object result = sut.getParameter(name); - + // Verify assertEquals(value, result); } @@ -336,13 +335,13 @@ public class JobRuntimeTest { @Test(expected = RuntimeException.class) public void testGetParameter_WrongName() throws Exception { // Exercise - sut.getParameter(""); + sut.getParameter(""); } @Test(expected = NullPointerException.class) public void testGetParameter_NullName() throws Exception { // Exercise - sut.getParameter(null); + sut.getParameter(null); } @Test @@ -355,7 +354,7 @@ public class JobRuntimeTest { statuses.add(event.getStatus()); } }); - + // Exercise sut.setStatus(JobStatus.WAIT_EXECUTOR); -- 2.54.0