summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/ActionDeserializerTest.java
blob: c98b408ab53f3a95c9434bfb0e7ff2c88782ab59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.onap.sdc.dcae.composition.restmodels.ruleeditor;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.ActionDeserializer;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.BaseAction;
import org.onap.sdc.dcae.composition.restmodels.ruleeditor.MapAction;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class ActionDeserializerTest {


	private Gson gson = new GsonBuilder().registerTypeAdapter(BaseAction.class, new ActionDeserializer()).create();

	@Test
	public void deserializerTest(){
		BaseAction action = new BaseAction();
		action.setActionType("map");
		String input = gson.toJson(action);
		BaseAction res = gson.fromJson(input, BaseAction.class);
		assertEquals(gson.toJson(res), input);
		assertTrue(res instanceof MapAction);
	}

}