Add custom conversion test

pull/137/head
johnniang 2019-03-14 22:07:15 +08:00
parent 06e18f3e8c
commit b2c933fe8b
1 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,31 @@
package cc.ryanc.halo.model.enums;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.convert.ConversionService;
import org.springframework.test.context.junit4.SpringRunner;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Attach origin test.
*
* @author johnniang
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class AttachOriginTest {
@Autowired
private ConversionService conversionService;
@Test
public void conversionTest() {
assertThat(conversionService.convert("SERVER", AttachOrigin.class), equalTo(AttachOrigin.SERVER));
assertThat(conversionService.convert("server", AttachOrigin.class), equalTo(AttachOrigin.SERVER));
assertThat(conversionService.convert("Server", AttachOrigin.class), equalTo(AttachOrigin.SERVER));
}
}