Search in sources :

Example 1 with StandardToken

use of com.minecolonies.api.colony.requestsystem.token.StandardToken in project minecolonies by Minecolonies.

the class StandardFactoryControllerTest method testGetNewInstance.

@Test
public void testGetNewInstance() {
    final UUID id = UUID.randomUUID();
    final IToken token = new StandardToken(id);
    final IToken output = StandardFactoryController.getInstance().getNewInstance(TypeConstants.ITOKEN, id);
    assertEquals(output, token);
}
Also used : StandardToken(com.minecolonies.api.colony.requestsystem.token.StandardToken) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) UUID(java.util.UUID) Test(org.junit.Test)

Example 2 with StandardToken

use of com.minecolonies.api.colony.requestsystem.token.StandardToken in project minecolonies by Minecolonies.

the class StandardFactoryControllerTest method testDeserialize.

@Test
public void testDeserialize() {
    final StandardToken standardToken = new StandardToken(UUID.randomUUID());
    final IToken token = standardToken;
    final NBTTagCompound compound = StandardFactoryController.getInstance().serialize(token);
    final IToken deserialize = StandardFactoryController.getInstance().deserialize(compound);
    assertEquals(token, deserialize);
}
Also used : StandardToken(com.minecolonies.api.colony.requestsystem.token.StandardToken) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Test(org.junit.Test)

Example 3 with StandardToken

use of com.minecolonies.api.colony.requestsystem.token.StandardToken in project minecolonies by Minecolonies.

the class StandardFactoryControllerTest method testSerialize.

@Test
public void testSerialize() {
    final StandardToken standardToken = new StandardToken(UUID.randomUUID());
    final IToken token = standardToken;
    final NBTTagCompound compound = StandardFactoryController.getInstance().serialize(token);
    assertTrue(compound.hasKey(StandardFactoryController.NBT_TYPE));
    assertTrue(compound.hasKey(StandardFactoryController.NBT_DATA));
    assertEquals(compound.getString(StandardFactoryController.NBT_TYPE), new TypeToken<StandardToken>() {
    }.toString());
    assertEquals(compound.getCompoundTag(StandardFactoryController.NBT_DATA).getLong(StandardTokenFactory.NBT_MSB), standardToken.getIdentifier().getMostSignificantBits());
    assertEquals(compound.getCompoundTag(StandardFactoryController.NBT_DATA).getLong(StandardTokenFactory.NBT_LSB), standardToken.getIdentifier().getLeastSignificantBits());
}
Also used : StandardToken(com.minecolonies.api.colony.requestsystem.token.StandardToken) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) TypeToken(com.google.common.reflect.TypeToken) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Test(org.junit.Test)

Aggregations

IToken (com.minecolonies.api.colony.requestsystem.token.IToken)3 StandardToken (com.minecolonies.api.colony.requestsystem.token.StandardToken)3 Test (org.junit.Test)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 TypeToken (com.google.common.reflect.TypeToken)1 UUID (java.util.UUID)1