BAEL-15988 : Java file movement
This commit is contained in:
+29
@@ -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());
|
||||
}
|
||||
}
|
||||
+28
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user