@@ -0,0 +1,2981 @@
+package org.monospark.spongematchers.type;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.monospark.spongematchers.testutil.HamcrestSpongeMatchers.matches;%0A%0Aimport java.util.Map;%0A%0Aimport org.junit.Test;%0Aimport org.monospark.spongematchers.matcher.SpongeMatcher;%0Aimport org.monospark.spongematchers.parser.SpongeMatcherParseException;%0Aimport org.monospark.spongematchers.parser.element.StringElement;%0Aimport org.monospark.spongematchers.parser.element.StringElementParser;%0Aimport org.spongepowered.api.block.BlockState;%0Aimport org.spongepowered.api.block.BlockType;%0Aimport org.spongepowered.api.block.trait.BlockTrait;%0Aimport org.spongepowered.api.data.DataContainer;%0Aimport org.spongepowered.api.data.DataQuery;%0Aimport org.spongepowered.api.data.MemoryDataContainer;%0A%0Aimport com.google.common.collect.Maps;%0A%0Apublic class BlockStateTypeTest %7B%0A%0A    @Test%0A    public void canMatch_NonBlockStateObject_ReturnsFalse() throws SpongeMatcherParseException %7B%0A        Object o = 5;%0A        %0A        boolean canMatch = MatcherType.BLOCK_STATE.canMatch(o);%0A        %0A        assertThat(canMatch, is(false));%0A    %7D%0A    %0A    @Test%0A    public void canMatch_BlockStateObject_ReturnsTrue() throws Exception %7B%0A        Object o = mock(BlockState.class);%0A%0A        boolean canMatch = MatcherType.BLOCK_STATE.canMatch(o);%0A        %0A        assertThat(canMatch, is(true));%0A    %7D%0A%0A    @SuppressWarnings(%7B%22unchecked%22, %22rawtypes%22%7D)%0A    @Test%0A    public void parseMatcher_ValidMapElement_ReturnsCorrectSpongeMatcher() throws SpongeMatcherParseException %7B%0A        StringElement element = StringElementParser.parseStringElement(%22%7B'type':%7B'id':'minecraft:appl.'%7D,%22%0A                + %22'traits':%7B'trait1':1,'trait2':false%7D,'data':%7B'boolean':true,'integer':%3E0%7D%7D%22);%0A%0A        SpongeMatcher%3CBlockState%3E matcher = MatcherType.BLOCK_STATE.parseMatcher(element);%0A%0A        BlockType type = mock(BlockType.class);%0A        when(type.getId()).thenReturn(%22minecraft:apple%22);%0A        BlockState state = mock(BlockState.class);%0A        when(state.getType()).thenReturn(type);%0A        BlockTrait%3CInteger%3E trait1 = mock(BlockTrait.class);%0A        when(trait1.getId()).thenReturn(%22trait1%22);%0A        when(trait1.getValueClass()).thenReturn(Integer.class);%0A        BlockTrait%3CBoolean%3E trait2 = mock(BlockTrait.class);%0A        when(trait2.getId()).thenReturn(%22trait2%22);%0A        when(trait2.getValueClass()).thenReturn(Boolean.class);%0A        Map traits = Maps.newHashMap();%0A        traits.put(trait1, 1);%0A        traits.put(trait2, false);%0A        when(state.getTraitMap()).thenReturn(traits);%0A        DataContainer container = new MemoryDataContainer();%0A        container.set(DataQuery.of(%22UnsafeData%22,%22boolean%22), true);%0A        container.set(DataQuery.of(%22UnsafeData%22,%22integer%22), 1);%0A        when(state.toContainer()).thenReturn(container);%0A        assertThat(matcher, matches(state));%0A    %7D%0A%7D%0A

Add tests for parsing BlockState matchers