mil.dod.th.ose.shared/test/mil/dod/th/ose/shared/TestSharedMessageUtils.java
@Test 
    public void testConvertListSimpleTypesMapEntrytoMapException()
    {
        //Create a list of map entries with duplicate keys
        List<SimpleTypesMapEntry> testList = new ArrayList<SimpleTypesMapEntry>(); 
        SimpleTypesMapEntry testEntry = SimpleTypesMapEntry.newBuilder().setKey("something").
                setValue(Multitype.newBuilder().setType(Type.STRING).setStringValue("test1")).build();  
        SimpleTypesMapEntry testEntry1 = SimpleTypesMapEntry.newBuilder().setKey("something").
                setValue(Multitype.newBuilder().setType(Type.STRING).setStringValue("test2")).build();
        testList.add(testEntry);
        testList.add(testEntry1);
        
        //catch IllegalArgument exception during conversion
        try
        {
            SharedMessageUtils.convertListSimpleTypesMapEntrytoMap(testList);
            fail("Expecting Exception");
        }
        catch (IllegalArgumentException e)
        {
            
        }
    }
/**
     * Test and verify that when there is a duplicate key entry in a list, IllegalArgumentException is caught
     */
Test and verify that when there is a duplicate key entry in a list, IllegalArgumentException is caught
Test and verify that when there is a duplicate key entry in a list IllegalArgumentException is caught
@Test 
    public void testConvertListSimpleTypesMapEntrytoMapException()
    {
        List<SimpleTypesMapEntry> testList = new ArrayList<SimpleTypesMapEntry>(); 
        SimpleTypesMapEntry testEntry = SimpleTypesMapEntry.newBuilder().setKey("something").
                setValue(Multitype.newBuilder().setType(Type.STRING).setStringValue("test1")).build();  
        SimpleTypesMapEntry testEntry1 = SimpleTypesMapEntry.newBuilder().setKey("something").
                setValue(Multitype.newBuilder().setType(Type.STRING).setStringValue("test2")).build();
        testList.add(testEntry);
        testList.add(testEntry1);
        try
        {
            SharedMessageUtils.convertListSimpleTypesMapEntrytoMap(testList);
            fail("Expecting Exception");
        }
        catch (IllegalArgumentException e)
        {
        }
    }
@ Test public void testConvertListSimpleTypesMapEntrytoMapException ( ) { List < SimpleTypesMapEntry > testList = new ArrayList < SimpleTypesMapEntry > ( ) ; SimpleTypesMapEntry testEntry = SimpleTypesMapEntry . newBuilder ( ) . setKey ( "something" ) . setValue ( Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "test1" ) ) . build ( ) ; SimpleTypesMapEntry testEntry1 = SimpleTypesMapEntry . newBuilder ( ) . setKey ( "something" ) . setValue ( Multitype . newBuilder ( ) . setType ( Type . STRING ) . setStringValue ( "test2" ) ) . build ( ) ; testList . add ( testEntry ) ; testList . add ( testEntry1 ) ; try { SharedMessageUtils . convertListSimpleTypesMapEntrytoMap ( testList ) ; fail ( "Expecting Exception" ) ; } catch ( IllegalArgumentException e ) { } }
Test and verify that when there is a duplicate key entry in a list, IllegalArgumentException is caught
Test and verify that when there is a duplicate key entry in a list IllegalArgumentException is caught
//Create a list of map entries with duplicate keys //catch IllegalArgument exception during conversion