Port build-tests tests to assertj
This commit is contained in:
@@ -437,8 +437,6 @@ project('spring-statemachine-build-tests') {
|
||||
testCompile 'com.h2database:h2'
|
||||
testCompile 'org.springframework.boot:spring-boot-starter'
|
||||
testCompile 'org.springframework:spring-test'
|
||||
testCompile 'org.hamcrest:hamcrest-core'
|
||||
testCompile 'org.hamcrest:hamcrest-library'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.statemachine.buildtests;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -55,8 +53,8 @@ public class EndSmokeTests extends AbstractBuildTests {
|
||||
|
||||
t.runWhile = false;
|
||||
t.join();
|
||||
assertThat(t.e, nullValue());
|
||||
assertThat(t.ok, is(true));
|
||||
assertThat(t.e).isNull();
|
||||
assertThat(t.ok).isTrue();
|
||||
}
|
||||
|
||||
private static class TestThread extends Thread {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 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.
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.statemachine.buildtests;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.resolveMachine;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -40,11 +39,11 @@ public class Gh737Tests extends AbstractBuildTests {
|
||||
StateMachine<Status, Event> machine = resolveMachine(context);
|
||||
doStartAndAssert(machine);
|
||||
|
||||
assertThat(machine.getState().getIds(), containsInAnyOrder(Status.ROOT, Status.S0));
|
||||
assertThat(machine.getState().getIds()).containsOnly(Status.ROOT, Status.S0);
|
||||
doSendEventAndConsumeAll(machine, Event.NEW);
|
||||
|
||||
assertThat(machine.getState().getIds(), containsInAnyOrder(Status.ROOT, Status.S2, Status.S21I, Status.S22I,
|
||||
Status.S23_IN_PROGRESS, Status.S24E));
|
||||
assertThat(machine.getState().getIds()).containsOnly(Status.ROOT, Status.S2, Status.S21I, Status.S22I,
|
||||
Status.S23_IN_PROGRESS, Status.S24E);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package org.springframework.statemachine.buildtests;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -54,7 +51,11 @@ public class LinkedRegionsTests extends AbstractBuildTests {
|
||||
.step().expectStateChanged(15).expectStates("S3").and()
|
||||
.build();
|
||||
plan.test();
|
||||
assertThat(listener.statesEntered, not(hasItem(startsWith("JOIN"))));
|
||||
assertThat(listener.statesEntered).satisfies(l -> {
|
||||
l.forEach(s -> {
|
||||
assertThat(s).doesNotStartWith("JOIN");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 the original author or authors.
|
||||
* Copyright 2017-2020 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.
|
||||
@@ -15,11 +15,7 @@
|
||||
*/
|
||||
package org.springframework.statemachine.buildtests;
|
||||
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAll;
|
||||
import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.resolveFactory;
|
||||
@@ -62,45 +58,45 @@ public class RedisPersistTests extends AbstractBuildTests {
|
||||
StateMachine<TestStates, TestEvents> stateMachine = stateMachineFactory.getStateMachine("testid");
|
||||
|
||||
doStartAndAssert(stateMachine);
|
||||
assertThat(stateMachine, notNullValue());
|
||||
assertThat(stateMachine.getId(), is("testid"));
|
||||
assertThat(stateMachine).isNotNull();
|
||||
assertThat(stateMachine.getId()).isEqualTo("testid");
|
||||
|
||||
doSendEventAndConsumeAll(stateMachine, TestEvents.E1);
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S2, TestStates.S20, TestStates.S30));
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S2, TestStates.S20, TestStates.S30);
|
||||
persister.persist(stateMachine, "xxx1");
|
||||
|
||||
doSendEventAndConsumeAll(stateMachine, TestEvents.E2);
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S2, TestStates.S21, TestStates.S30));
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S2, TestStates.S21, TestStates.S30);
|
||||
persister.persist(stateMachine, "xxx2");
|
||||
|
||||
doSendEventAndConsumeAll(stateMachine, TestEvents.E3);
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S4));
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S4);
|
||||
persister.persist(stateMachine, "xxx3");
|
||||
|
||||
stateMachine = stateMachineFactory.getStateMachine();
|
||||
assertThat(stateMachine, notNullValue());
|
||||
assertThat(stateMachine.getId(), nullValue());
|
||||
assertThat(stateMachine).isNotNull();
|
||||
assertThat(stateMachine.getId()).isNull();
|
||||
stateMachine = persister.restore(stateMachine, "xxx1");
|
||||
assertThat(stateMachine.getId(), is("testid"));
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S2, TestStates.S20, TestStates.S30));
|
||||
assertThat(stateMachine.getId()).isEqualTo("testid");
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S2, TestStates.S20, TestStates.S30);
|
||||
doSendEventAndConsumeAll(stateMachine, TestEvents.E2);
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S2, TestStates.S21, TestStates.S30));
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S2, TestStates.S21, TestStates.S30);
|
||||
|
||||
stateMachine = stateMachineFactory.getStateMachine();
|
||||
assertThat(stateMachine, notNullValue());
|
||||
assertThat(stateMachine.getId(), nullValue());
|
||||
assertThat(stateMachine).isNotNull();
|
||||
assertThat(stateMachine.getId()).isNull();
|
||||
stateMachine = persister.restore(stateMachine, "xxx2");
|
||||
assertThat(stateMachine.getId(), is("testid"));
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S2, TestStates.S21, TestStates.S30));
|
||||
assertThat(stateMachine.getId()).isEqualTo("testid");
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S2, TestStates.S21, TestStates.S30);
|
||||
doSendEventAndConsumeAll(stateMachine, TestEvents.E3);
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S4));
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S4);
|
||||
|
||||
stateMachine = stateMachineFactory.getStateMachine();
|
||||
assertThat(stateMachine, notNullValue());
|
||||
assertThat(stateMachine.getId(), nullValue());
|
||||
assertThat(stateMachine).isNotNull();
|
||||
assertThat(stateMachine.getId()).isNull();
|
||||
stateMachine = persister.restore(stateMachine, "xxx3");
|
||||
assertThat(stateMachine.getId(), is("testid"));
|
||||
assertThat(stateMachine.getState().getIds(), containsInAnyOrder(TestStates.S4));
|
||||
assertThat(stateMachine.getId()).isEqualTo("testid");
|
||||
assertThat(stateMachine.getState().getIds()).containsOnly(TestStates.S4);
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
Reference in New Issue
Block a user