Search in sources :

Example 11 with JsonProcessorInjectionMap

use of com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap in project Engine by VoltzEngine-Project.

the class TestProcessorInjection method testJsonLong.

@Test
public void testJsonLong() {
    JsonProcessorInjectionMap map = new JsonProcessorInjectionMap(InjectionTestClass.class);
    InjectionTestClass object = new InjectionTestClass();
    assertTrue(map.handle(object, "l", new JsonPrimitive(1l)));
    assertEquals(1l, object.l);
    assertTrue(map.handle(object, "l2", new JsonPrimitive(2l)));
    assertEquals(2l, object.l);
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) JsonProcessorInjectionMap(com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap) Test(org.junit.Test)

Example 12 with JsonProcessorInjectionMap

use of com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap in project Engine by VoltzEngine-Project.

the class TestProcessorInjection method testInit.

@Test
public void testInit() {
    JsonProcessorInjectionMap map = new JsonProcessorInjectionMap(InjectionTestClass.class);
    assertTrue(map.injectionFields.containsKey("key"));
    assertNotNull(map.injectionFields.get("key"));
    assertTrue(map.injectionMethods.containsKey("key2"));
    assertNotNull(map.injectionMethods.get("key2"));
}
Also used : JsonProcessorInjectionMap(com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap) Test(org.junit.Test)

Example 13 with JsonProcessorInjectionMap

use of com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap in project Engine by VoltzEngine-Project.

the class TestProcessorInjection method testJsonElement.

@Test
public void testJsonElement() {
    JsonProcessorInjectionMap map = new JsonProcessorInjectionMap(InjectionTestClass.class);
    InjectionTestClass object = new InjectionTestClass();
    JsonElement element = createTestElement();
    assertTrue(map.handle(object, "element", element));
    assertSame(element, object.element);
    object.element = null;
    assertTrue(map.handle(object, "element2", element));
    assertSame(element, object.element);
}
Also used : JsonElement(com.google.gson.JsonElement) JsonProcessorInjectionMap(com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap) Test(org.junit.Test)

Example 14 with JsonProcessorInjectionMap

use of com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap in project Engine by VoltzEngine-Project.

the class TestProcessorInjection method testJsonBoolean.

@Test
public void testJsonBoolean() {
    JsonProcessorInjectionMap map = new JsonProcessorInjectionMap(InjectionTestClass.class);
    InjectionTestClass object = new InjectionTestClass();
    JsonPrimitive primitive = new JsonPrimitive(true);
    assertTrue(map.handle(object, "bool", primitive));
    assertTrue(object.bool);
    assertTrue(map.handle(object, "bool2", primitive));
    assertTrue(object.bool);
}
Also used : JsonPrimitive(com.google.gson.JsonPrimitive) JsonProcessorInjectionMap(com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap) Test(org.junit.Test)

Example 15 with JsonProcessorInjectionMap

use of com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap in project Engine by VoltzEngine-Project.

the class TestProcessorInjection method testBoolean.

@Test
public void testBoolean() {
    JsonProcessorInjectionMap map = new JsonProcessorInjectionMap(InjectionTestClass.class);
    InjectionTestClass object = new InjectionTestClass();
    assertTrue(map.handle(object, "bool", true));
    assertTrue(object.bool);
    assertTrue(map.handle(object, "bool2", true));
    assertTrue(object.bool);
}
Also used : JsonProcessorInjectionMap(com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap) Test(org.junit.Test)

Aggregations

JsonProcessorInjectionMap (com.builtbroken.mc.lib.json.loading.JsonProcessorInjectionMap)19 Test (org.junit.Test)18 JsonPrimitive (com.google.gson.JsonPrimitive)7 JsonElement (com.google.gson.JsonElement)2 ITileEventListener (com.builtbroken.mc.api.tile.listeners.ITileEventListener)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1