Package org.eclipse.sapphire

Examples of org.eclipse.sapphire.MasterConversionService


   
    @Test
   
    public void testStringToEnum_ToString() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( ThreeChoiceAnswerToString.YES, service.convert( "YES", ThreeChoiceAnswerToString.class ) );
        assertEquals( ThreeChoiceAnswerToString.MAYBE, service.convert( "MAYBE", ThreeChoiceAnswerToString.class ) );
        assertEquals( ThreeChoiceAnswerToString.NO, service.convert( "NO", ThreeChoiceAnswerToString.class ) );
       
        assertNull( service.convert( "1", ThreeChoiceAnswerToString.class ) );
        assertNull( service.convert( "0", ThreeChoiceAnswerToString.class ) );
        assertNull( service.convert( "-1", ThreeChoiceAnswerToString.class ) );
    }
View Full Code Here


{
    @Test
   
    public void testStringToBoolean() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( Boolean.TRUE, service.convert( "true", Boolean.class ) );
        assertEquals( Boolean.TRUE, service.convert( "TRUE", Boolean.class ) );
        assertEquals( Boolean.TRUE, service.convert( "True", Boolean.class ) );
        assertEquals( Boolean.TRUE, service.convert( "tRuE", Boolean.class ) );
       
        assertEquals( Boolean.FALSE, service.convert( "false", Boolean.class ) );
        assertEquals( Boolean.FALSE, service.convert( "FALSE", Boolean.class ) );
        assertEquals( Boolean.FALSE, service.convert( "False", Boolean.class ) );
        assertEquals( Boolean.FALSE, service.convert( "fAlSe", Boolean.class ) );
       
        assertNull( service.convert( "yes", Boolean.class ) );
        assertNull( service.convert( "no", Boolean.class ) );
        assertNull( service.convert( "0", Boolean.class ) );
        assertNull( service.convert( "1", Boolean.class ) );
        assertNull( service.convert( "abcdef", Boolean.class ) );
    }
View Full Code Here

   
    @Test

    public void testEnumToString_Plain() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "YES", service.convert( ThreeChoiceAnswer.YES, String.class ) );
        assertEquals( "MAYBE", service.convert( ThreeChoiceAnswer.MAYBE, String.class ) );
        assertEquals( "NO", service.convert( ThreeChoiceAnswer.NO, String.class ) );
    }
View Full Code Here

   
    @Test

    public void testEnumToString_Customized() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "yes", service.convert( ThreeChoiceAnswerCustomized.YES, String.class ) );
        assertEquals( "maybe", service.convert( ThreeChoiceAnswerCustomized.MAYBE, String.class ) );
        assertEquals( "no", service.convert( ThreeChoiceAnswerCustomized.NO, String.class ) );
    }
View Full Code Here

   
    @Test

    public void testEnumToString_ToString() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "YES", service.convert( ThreeChoiceAnswerToString.YES, String.class ) );
        assertEquals( "MAYBE", service.convert( ThreeChoiceAnswerToString.MAYBE, String.class ) );
        assertEquals( "NO", service.convert( ThreeChoiceAnswerToString.NO, String.class ) );
    }
View Full Code Here

   
    @Test

    public void testBooleanToString() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "true", service.convert( Boolean.TRUE, String.class ) );
        assertEquals( "false", service.convert( Boolean.FALSE, String.class ) );
    }
View Full Code Here

   
    @Test
   
    public void testStringToByte() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( Byte.valueOf( (byte) -128 ), service.convert( "-128", Byte.class ) );
        assertEquals( Byte.valueOf( (byte) -48 ), service.convert( "-48", Byte.class ) );
        assertEquals( Byte.valueOf( (byte) 0 ), service.convert( "0", Byte.class ) );
        assertEquals( Byte.valueOf( (byte) 47 ), service.convert( "47", Byte.class ) );
        assertEquals( Byte.valueOf( (byte) 127 ), service.convert( "127", Byte.class ) );
    }
View Full Code Here

   
    @Test

    public void testByteToString() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "-128", service.convert( Byte.valueOf( (byte) -128 ), String.class ) );
        assertEquals( "-48", service.convert( Byte.valueOf( (byte) -48 ), String.class ) );
        assertEquals( "0", service.convert( Byte.valueOf( (byte) 0 ), String.class ) );
        assertEquals( "47", service.convert( Byte.valueOf( (byte) 47 ), String.class ) );
        assertEquals( "127", service.convert( Byte.valueOf( (byte) 127 ), String.class ) );
    }
View Full Code Here

   
    @Test
   
    public void testStringToShort() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( Short.valueOf( (short) -32768 ), service.convert( "-32768", Short.class ) );
        assertEquals( Short.valueOf( (short) -128 ), service.convert( "-128", Short.class ) );
        assertEquals( Short.valueOf( (short) -48 ), service.convert( "-48", Short.class ) );
        assertEquals( Short.valueOf( (short) 0 ), service.convert( "0", Short.class ) );
        assertEquals( Short.valueOf( (short) 47 ), service.convert( "47", Short.class ) );
        assertEquals( Short.valueOf( (short) 127 ), service.convert( "127", Short.class ) );
        assertEquals( Short.valueOf( (short) 32767 ), service.convert( "32767", Short.class ) );
    }
View Full Code Here

   
    @Test

    public void testShortToString() throws Exception
    {
        final MasterConversionService service = Sapphire.service( MasterConversionService.class );
       
        assertEquals( "-32768", service.convert( Short.valueOf( (short) -32768 ), String.class ) );
        assertEquals( "-128", service.convert( Short.valueOf( (short) -128 ), String.class ) );
        assertEquals( "-48", service.convert( Short.valueOf( (short) -48 ), String.class ) );
        assertEquals( "0", service.convert( Short.valueOf( (short) 0 ), String.class ) );
        assertEquals( "47", service.convert( Short.valueOf( (short) 47 ), String.class ) );
        assertEquals( "127", service.convert( Short.valueOf( (short) 127 ), String.class ) );
        assertEquals( "32767", service.convert( Short.valueOf( (short) 32767 ), String.class ) );
    }
View Full Code Here

TOP

Related Classes of org.eclipse.sapphire.MasterConversionService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.