BAEL-15988 : Java file movement

This commit is contained in:
sampada
2020-02-11 10:52:06 +05:30
parent eeacffa08d
commit 2cc05b370b
13 changed files with 0 additions and 2 deletions
@@ -0,0 +1,29 @@
package org.baeldung.boot.jsoncomponent;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.scene.paint.Color;
import org.baeldung.boot.jsoncomponent.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
@JsonTest
@RunWith(SpringRunner.class)
public class UserJsonDeserializerIntegrationTest {
@Autowired
private ObjectMapper objectMapper;
@Test
public void testDeserialize() throws IOException {
User user = objectMapper.readValue("{\"favoriteColor\":\"#f0f8ff\"}", User.class);
assertEquals(Color.ALICEBLUE, user.getFavoriteColor());
}
}
@@ -0,0 +1,28 @@
package org.baeldung.boot.jsoncomponent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.scene.paint.Color;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;
import org.springframework.test.context.junit4.SpringRunner;
import static org.junit.Assert.assertEquals;
import org.baeldung.boot.jsoncomponent.User;
@JsonTest
@RunWith(SpringRunner.class)
public class UserJsonSerializerIntegrationTest {
@Autowired
private ObjectMapper objectMapper;
@Test
public void testSerialization() throws JsonProcessingException {
String json = objectMapper.writeValueAsString(new User(Color.ALICEBLUE));
assertEquals("{\"favoriteColor\":\"#f0f8ff\"}", json);
}
}