feat(loader): ConditionDto/EffectDto with toModel mapping
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package thb.jeanluc.adventure.loader.dto;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import thb.jeanluc.adventure.loader.WorldLoadException;
|
||||
import thb.jeanluc.adventure.model.Condition;
|
||||
import thb.jeanluc.adventure.model.Effect;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class ConditionEffectDtoTest {
|
||||
@Test
|
||||
void conditionToModel() {
|
||||
assertThat(new ConditionDto("power_on", null, null).toModel())
|
||||
.isEqualTo(new Condition(Condition.Type.FLAG, "power_on"));
|
||||
assertThat(new ConditionDto(null, "x", null).toModel().type())
|
||||
.isEqualTo(Condition.Type.NOT_FLAG);
|
||||
assertThat(new ConditionDto(null, null, "lamp").toModel().type())
|
||||
.isEqualTo(Condition.Type.HAS_ITEM);
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyConditionThrows() {
|
||||
assertThatThrownBy(() -> new ConditionDto(null, null, null).toModel())
|
||||
.isInstanceOf(WorldLoadException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void effectToModel() {
|
||||
assertThat(new EffectDto("p", null, null, null, null).toModel())
|
||||
.isEqualTo(new Effect(Effect.Type.SET_FLAG, "p"));
|
||||
assertThat(new EffectDto(null, null, "key", null, null).toModel().type())
|
||||
.isEqualTo(Effect.Type.GIVE_ITEM);
|
||||
assertThat(new EffectDto(null, null, null, null, "boo").toModel().type())
|
||||
.isEqualTo(Effect.Type.SAY);
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyEffectThrows() {
|
||||
assertThatThrownBy(() -> new EffectDto(null, null, null, null, null).toModel())
|
||||
.isInstanceOf(WorldLoadException.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user