use of org.summerb.easycrud.api.dto.EntityChangedEvent in project summerb by skarpushin.
the class EntityChangedEventAdapter method deserialize.
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public EntityChangedEvent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
Class<? extends DtoBase> klass = resolveParametersClass(jsonObject);
JsonElement jsonElement = jsonObject.get(INSTANCE);
DtoBase value = context.deserialize(jsonElement, klass);
ChangeType changeType = context.deserialize(jsonObject.get("ct"), ChangeType.class);
return new EntityChangedEvent(value, changeType);
}
use of org.summerb.easycrud.api.dto.EntityChangedEvent in project summerb by skarpushin.
the class EntityChangedEventAdapterTest method testDeserializeExpectOkForAllowedClass.
@SuppressWarnings("rawtypes")
@Test
public void testDeserializeExpectOkForAllowedClass() {
Gson gson = getFixture();
EntityChangedEvent evt = gson.fromJson("{\"ct\": \"asdasd\", \"vt\": \"org.summerb.easycrud.api.dto.tools.TestDto\", \"v\": {\"email\": \"asd\"}}", EntityChangedEvent.class);
assertNotNull(evt);
assertEquals("asd", ((TestDto) evt.getValue()).getEmail());
}
use of org.summerb.easycrud.api.dto.EntityChangedEvent in project summerb by skarpushin.
the class EntityChangedEventAdapterTest method testDeserializeExpectExceptionForNotAllowedClass.
@Test(expected = IllegalArgumentException.class)
@SuppressWarnings({ "rawtypes", "unused" })
public void testDeserializeExpectExceptionForNotAllowedClass() {
Gson gson = getFixture();
EntityChangedEvent evt = gson.fromJson("{\"ct\": \"asdasd\", \"vt\": \"javax.print.event.PrintEvent\", \"v\": {\"source\": \"asd\"}}", EntityChangedEvent.class);
fail("We should be dead by now");
}
Aggregations