Terasology / ModuleTestingEnvironment

3 stars 15 forks source link

test: fix TestEventReceiverTest by giving target entity a DummyComponent #56

Closed skaldarnar closed 3 years ago

skaldarnar commented 3 years ago

By working on #55 we discovered that some of the tests are broken independent of any gestalt and module management issues.

This PR fixes those tests (at least locally) by giving the target entity a DummyComponent, as is expected by DummySystem.

keturn commented 3 years ago

Could we add a component filter to DummySystem's @ReceiveEvent instead? Would that be better?

skaldarnar commented 3 years ago

Could we add a component filter to DummySystem's @ReceiveEvent instead? Would that be better?

Done in 9e07194

I think we need both, at least I hope that the goal of sending this event is that the system reacts to it... :eyes:

keturn commented 3 years ago

oh, I was thinking more like

    @ReceiveEvent(components=DummyComponent.class)
    public void onDummyEvent(DummyEvent event, EntityRef entity /*, DummyComponent component */) 

but if we can put the component in the signature to skip the entity.getComponent call, that's handy too.

Does it do the same thing as naming the component in the annotation, or is that component argument nullable?

either way, I'm not too fussed about it, feel free to merge 👍

keturn commented 3 years ago

I think last time I looked at this I got really distracted by the question of what was registering that system and if there were any way to selectively avoid it.

skaldarnar commented 3 years ago

Does it do the same thing as naming the component in the annotation, or is that component argument nullable?

@keturn afaik these arguments are not nullable and serve the same purpose as listing them in the annotation, except that you can take a shortcut for giving them a name and retrieving them from the entity.

I couldn't find any good/clear documentation on this, though (for the annotation it is described in the Javadoc). There's some information in the Entity System Tutorial as well as in the Event Interaction Tutorial.

The engine wiki has some info on Events in Detail which is not nearly as detailed as it should be :see_no_evil: ... but another page on Processing Events has more info on it :upside_down_face: