Fix OnExtendedStateChanged with key

- Fix case where method was annotated with
  @OnExtendedStateChanged(key = "V1"), V1 was
  changed which didn't result call to that method.
- Backport #387
- Relates #307
This commit is contained in:
Janne Valkealahti
2017-07-09 08:42:11 +01:00
parent 1e60b7abfa
commit f268999400
2 changed files with 13 additions and 0 deletions

View File

@@ -146,6 +146,8 @@ public abstract class StateMachineUtils {
for (Object o : ObjectUtils.toObjectArray(object)) {
c.add(o.toString());
}
} else if (object != null) {
c.add(object.toString());
}
return c;
}

View File

@@ -156,6 +156,9 @@ public class MethodAnnotationTests extends AbstractStateMachineTests {
assertThat(bean5.onExtendedStateChanged2Count, is(1));
assertThat(bean5.onExtendedStateChanged2Value, is("V1val"));
assertThat(bean5.onExtendedStateChangedKeyV1Latch.await(1, TimeUnit.SECONDS), is(true));
assertThat(bean5.onExtendedStateChangedKeyV1Count, is(1));
assertThat(bean5.onExtendedStateChangedKeyV2Latch.await(1, TimeUnit.SECONDS), is(false));
assertThat(bean5.onExtendedStateChangedKeyV2Count, is(0));
}
@@ -520,10 +523,12 @@ public class MethodAnnotationTests extends AbstractStateMachineTests {
CountDownLatch onExtendedStateChanged1Latch = new CountDownLatch(1);
CountDownLatch onExtendedStateChanged2Latch = new CountDownLatch(1);
CountDownLatch onExtendedStateChangedKeyV1Latch = new CountDownLatch(1);
CountDownLatch onExtendedStateChangedKeyV2Latch = new CountDownLatch(1);
int onExtendedStateChanged1Count = 0;
int onExtendedStateChanged2Count = 0;
Object onExtendedStateChanged2Value = null;
int onExtendedStateChangedKeyV1Count = 0;
int onExtendedStateChangedKeyV2Count = 0;
@OnExtendedStateChanged
@@ -539,6 +544,12 @@ public class MethodAnnotationTests extends AbstractStateMachineTests {
onExtendedStateChanged2Latch.countDown();
}
@OnExtendedStateChanged(key = "V1")
public void onExtendedStateChangedKeyV1() {
onExtendedStateChangedKeyV1Count++;
onExtendedStateChangedKeyV1Latch.countDown();
}
@OnExtendedStateChanged(key = "V2")
public void onExtendedStateChangedKeyV2() {
onExtendedStateChangedKeyV2Count++;