final String[] values = new String[] { "1.0", "2.0", "3.0", "4.0" };
widget.setArginValuesList(values);
Sleeper.SECONDS.sleep(3);
final CommandListenerImpl listenerSpy = new CommandListenerImpl();
widget.addCommandListener(listenerSpy);
tth.click(getButton(widget));
// scalar must not be notify
assertThat(
listenerSpy.isLaterNotified("resultNumberScalarValueChange",
2000)).isFalse();
assertThat(
listenerSpy.isLaterNotified("resultStringScalarValueChange",
2000)).isFalse();
assertThat(
listenerSpy.isLaterNotified("resultBooleanValueChange", 2000))
.isFalse();
assertThat(
listenerSpy.isLaterNotified(
"resultSpectrumValueChange(String)", 2000)).isTrue();
assertThat(
listenerSpy.isLaterNotified(
"resultSpectrumValueChange(String[])", 2000)).isTrue();
// check listener is notify only one time.
Sleeper.SECONDS.sleep(2);
assertThat(listenerSpy.getNotifyCount()).isEqualTo(2);
// check values
assertThat(
listenerSpy.getNotification("resultSpectrumValueChange(String)"))
.isEqualTo("1.0,2.0,3.0,4.0,");
final String[] res = (String[]) listenerSpy
.getNotification("resultSpectrumValueChange(String[])");
assertThat(res).isEqualTo(values);
// remove listener and check is no more notify
widget.removeCommandListener(listenerSpy);
listenerSpy.reset();
tth.click(getButton(widget));
assertEquals("listener shoudn't be notify", 0,
listenerSpy.getNotifyCount());
// clean
widget.stop();
jf1.dispose();
}