Skip to content
Prev Previous commit
Next Next commit
Cleanup to resolve code smells
  • Loading branch information
charlesfinley committed Mar 3, 2021
commit 9b9800a1cf55dbb0951841aec3db08fee5321f4a
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
/***
* empty test
*/
public class SagaApplicationTest {
class SagaApplicationTest {
@Test
public void shouldExecuteWithoutException() {
void shouldExecuteWithoutException() {
assertDoesNotThrow(() -> SagaApplication.main(new String[]{}));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an extra line here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want an empty line after the method declaration and before the assertion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes an empty line at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, duh. I need coffee. Updated!

Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
/**
* test to check choreography saga
*/
public class SagaChoreographyTest {
class SagaChoreographyTest {


@Test
public void executeTest() {
void executeTest() {
var sd = serviceDiscovery();
var service = sd.findAny();
var badOrderSaga = service.execute(newSaga("bad_order"));
var goodOrderSaga = service.execute(newSaga("good_order"));

assertEquals(badOrderSaga.getResult(), Saga.SagaResult.ROLLBACKED);
assertEquals(goodOrderSaga.getResult(), Saga.SagaResult.FINISHED);
assertEquals(Saga.SagaResult.ROLLBACKED, badOrderSaga.getResult());
assertEquals(Saga.SagaResult.FINISHED, goodOrderSaga.getResult());
}

private static Saga newSaga(Object value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
/**
* empty test
*/
public class SagaApplicationTest {
class SagaApplicationTest {

@Test
public void mainTest() {
void mainTest() {
SagaApplication.main(new String[]{});
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add an empty line here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
/**
* test to test orchestration logic
*/
public class SagaOrchestratorInternallyTest {
class SagaOrchestratorInternallyTest {

private final List<String> records = new ArrayList<>();

@Test
public void executeTest() {
void executeTest() {
var sagaOrchestrator = new SagaOrchestrator(newSaga(), serviceDiscovery());
var result = sagaOrchestrator.execute(1);
assertEquals(result, Result.ROLLBACK);
assertEquals(Result.ROLLBACK, result);
assertArrayEquals(
records.toArray(new String[]{}),
new String[]{"+1", "+2", "+3", "+4", "-4", "-3", "-2", "-1"});
new String[]{"+1", "+2", "+3", "+4", "-4", "-3", "-2", "-1"},
records.toArray(new String[]{}));
}

private static Saga newSaga() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
/**
* test to check general logic
*/
public class SagaOrchestratorTest {
class SagaOrchestratorTest {

@Test
public void execute() {
void execute() {
SagaOrchestrator sagaOrchestrator = new SagaOrchestrator(newSaga(), serviceDiscovery());
Saga.Result badOrder = sagaOrchestrator.execute("bad_order");
Saga.Result crashedOrder = sagaOrchestrator.execute("crashed_order");

assertEquals(badOrder, Saga.Result.ROLLBACK);
assertEquals(crashedOrder, Saga.Result.CRASHED);
assertEquals(Saga.Result.ROLLBACK, badOrder);
assertEquals(Saga.Result.CRASHED, crashedOrder);
}

private static Saga newSaga() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

public class AppTest {
class AppTest {

@Test
public void shouldExecuteApplicationWithoutException() {
void shouldExecuteApplicationWithoutException() {
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class SkeletonTest {

class SkeletonTest {

private static Skeleton skeleton;

Expand All @@ -44,36 +47,36 @@ public static void tearDown() {
}

@Test
public void testUpdateForPatrollingLeft() {
void testUpdateForPatrollingLeft() {
skeleton.patrollingLeft = true;
skeleton.setPosition(50);
skeleton.update();
assertEquals(49, skeleton.getPosition());
}

@Test
public void testUpdateForPatrollingRight() {
void testUpdateForPatrollingRight() {
skeleton.patrollingLeft = false;
skeleton.setPosition(50);
skeleton.update();
assertEquals(51, skeleton.getPosition());
}

@Test
public void testUpdateForReverseDirectionFromLeftToRight() {
void testUpdateForReverseDirectionFromLeftToRight() {
skeleton.patrollingLeft = true;
skeleton.setPosition(1);
skeleton.update();
assertEquals(0, skeleton.getPosition());
assertEquals(false, skeleton.patrollingLeft);
assertFalse(skeleton.patrollingLeft);
}

@Test
public void testUpdateForReverseDirectionFromRightToLeft() {
void testUpdateForReverseDirectionFromRightToLeft() {
skeleton.patrollingLeft = false;
skeleton.setPosition(99);
skeleton.update();
assertEquals(100, skeleton.getPosition());
assertEquals(true, skeleton.patrollingLeft);
assertTrue(skeleton.patrollingLeft);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class StatueTest {
class StatueTest {

private static Statue statue;

Expand All @@ -44,14 +44,14 @@ public static void tearDown() {
}

@Test
public void testUpdateForPendingShoot() {
void testUpdateForPendingShoot() {
statue.frames = 10;
statue.update();
assertEquals(11, statue.frames);
}

@Test
public void testUpdateForShooting() {
void testUpdateForShooting() {
statue.frames = 19;
statue.update();
assertEquals(0, statue.frames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

public class WorldTest {
class WorldTest {

private static World world;

Expand All @@ -44,19 +44,19 @@ public static void tearDown() {
}

@Test
public void testRun() {
void testRun() {
world.run();
assertEquals(true, world.isRunning);
assertTrue(world.isRunning);
}

@Test
public void testStop() {
void testStop() {
world.stop();
assertEquals(false, world.isRunning);
assertFalse(world.isRunning);
}

@Test
public void testAddEntity() {
void testAddEntity() {
var entity = new Skeleton(1);
world.addEntity(entity);
assertEquals(entity, world.entities.get(0));
Expand Down