Skip to content

Commit

Permalink
Switch to assertj assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
kindlich committed May 18, 2021
1 parent bdbf70d commit eea6be0
Showing 1 changed file with 7 additions and 10 deletions.
Expand Up @@ -8,17 +8,14 @@

import java.util.*;

import static org.assertj.core.api.Assertions.*;

class IngredientConverterTest extends CraftTweakerTest {

private static void assertIsEmptyStack(IIngredient result) {

Assertions.assertTrue(result instanceof IItemStack);
Assertions.assertSame(ItemStack.EMPTY, ((IItemStack) result).getInternal());
}

private static <T> void assertInstanceOf(T object, Class<? extends T> cls) {

Assertions.assertTrue(cls.isInstance(object), "Expected " + object + " to be instanceof " + cls.getCanonicalName());
assertThat(result).isInstanceOfSatisfying(IItemStack.class,
stack -> assertThat(stack.getInternal()).isSameAs(ItemStack.EMPTY));
}

@Test
Expand All @@ -43,7 +40,7 @@ void itemStackReturnsIItemStack() {
final IIngredient result = IngredientConverter.fromIngredient(ingredient);

//Assert
Assertions.assertEquals(expectedStack, result);
assertThat(expectedStack).isEqualTo(result);
}

@Test
Expand All @@ -64,8 +61,8 @@ void itemListReturnsListIngredient() {
final IIngredient result = IngredientConverter.fromIngredient(ingredient);

//Assert
assertInstanceOf(result, MCIngredientList.class);
Assertions.assertArrayEquals(expectedIngredients, ((MCIngredientList) result).getIngredients());
assertThat(result).isInstanceOfSatisfying(MCIngredientList.class,
list -> assertThat(list.getIngredients()).contains(expectedIngredients));
}

//TODO, how to test tags here?
Expand Down

0 comments on commit eea6be0

Please sign in to comment.