Create class for sulfuras items

This commit is contained in:
Alvaro Gomez Traveso 2022-12-16 11:42:22 +01:00
parent 0c801848ed
commit 3bd5d5ffdc
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,21 @@
package com.gildedrose.items;
import com.gildedrose.Quality;
import com.gildedrose.SellIn;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
public class SulfurasItem extends GildedRoseItem {
static final Quality DEFAULT_QUALITY = Quality.create(80);
public SulfurasItem(SellIn sellIn) {
super("Sulfuras", sellIn, DEFAULT_QUALITY, Boolean.FALSE);
}
@Override
protected Quality nextQuality(Quality previous) {
// being a legendary item, never has to be sold or decreases in Quality
return previous.copy();
}
}

View File

@ -0,0 +1,22 @@
package com.gildedrose.items;
import static org.assertj.core.api.Assertions.assertThat;
import com.gildedrose.Quality;
import com.gildedrose.SellIn;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
class SulfurasItemTest {
private final SulfurasItem item = new SulfurasItem(SellIn.create(0));
@Nested
class nextQuality {
@Test
void should_never_update_quality() {
Quality nextQuality = item.nextQuality(SulfurasItem.DEFAULT_QUALITY);
assertThat(nextQuality).isEqualTo(SulfurasItem.DEFAULT_QUALITY);
}
}
}