mil.dod.th.ose.remote/test/mil/dod/th/ose/remote/ccomms/TestPhysicalLinkMessageService.java
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testSetPropertyRequest() throws IOException, 
        IllegalArgumentException, IllegalStateException, FactoryException
    {
        UUID uuid = UUID.randomUUID();
        // build request
        Multitype multi = Multitype.newBuilder().setStringValue("valueA").setType(Type.STRING).build();
        SimpleTypesMapEntry type = SimpleTypesMapEntry.newBuilder().setKey("AKey").setValue(multi).build();
        SetPropertyRequestData request = SetPropertyRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(uuid)).addProperties(type).build();
        PhysicalLinkNamespace physLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.SetPropertyRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(physLinkMessage);
        TerraHarvestMessage message = createPhysicalLinkMessage(physLinkMessage);
        
        //mock necessary objects/actions
        PhysicalLink physLink = mock(PhysicalLink.class);
        when(physLink.getUuid()).thenReturn(uuid);
        
        Map<String, Object> propsToSet = new HashMap<>();
        propsToSet.put("AKey", "");
        
        when(physLink.getProperties()).thenReturn(propsToSet);
        
        List<PhysicalLink> phyLinkList = new ArrayList<PhysicalLink>();
        phyLinkList.add(physLink);
        when(m_CustomCommsService.getPhysicalLinks()).thenReturn(phyLinkList);
        
        // mock the channel the message came from
        RemoteChannel channel = mock(RemoteChannel.class);
        
        m_SUT.handleMessage(message, payload, channel);
        
        verify(m_MessageFactory, times(1)).createPhysicalLinkResponseMessage(eq(message), 
                eq(PhysicalLinkMessageType.SetPropertyResponse), eq((Message)null));
        
        ArgumentCaptor<Map> dictCaptor = ArgumentCaptor.forClass(Map.class);
        verify(physLink, times(1)).setProperties(dictCaptor.capture());
        
        Map<String, Object> capDict = dictCaptor.getValue();
        assertThat(capDict.size(), is(1));
        
        assertThat((String)capDict.get("AKey"), is("valueA"));
    }
/**
     * Verify that a property request is properly handled
     */
Verify that a property request is properly handled
Verify that a property request is properly handled
@SuppressWarnings({"unchecked", "rawtypes"})
    @Test
    public void testSetPropertyRequest() throws IOException, 
        IllegalArgumentException, IllegalStateException, FactoryException
    {
        UUID uuid = UUID.randomUUID();
        Multitype multi = Multitype.newBuilder().setStringValue("valueA").setType(Type.STRING).build();
        SimpleTypesMapEntry type = SimpleTypesMapEntry.newBuilder().setKey("AKey").setValue(multi).build();
        SetPropertyRequestData request = SetPropertyRequestData.newBuilder().
                setUuid(SharedMessageUtils.convertUUIDToProtoUUID(uuid)).addProperties(type).build();
        PhysicalLinkNamespace physLinkMessage = PhysicalLinkNamespace.newBuilder().
                setType(PhysicalLinkMessageType.SetPropertyRequest).
                setData(request.toByteString()).build();
        TerraHarvestPayload payload = createPayload(physLinkMessage);
        TerraHarvestMessage message = createPhysicalLinkMessage(physLinkMessage);
        PhysicalLink physLink = mock(PhysicalLink.class);
        when(physLink.getUuid()).thenReturn(uuid);
        Map<String, Object> propsToSet = new HashMap<>();
        propsToSet.put("AKey", "");
        when(physLink.getProperties()).thenReturn(propsToSet);
        List<PhysicalLink> phyLinkList = new ArrayList<PhysicalLink>();
        phyLinkList.add(physLink);
        when(m_CustomCommsService.getPhysicalLinks()).thenReturn(phyLinkList);
        RemoteChannel channel = mock(RemoteChannel.class);
        m_SUT.handleMessage(message, payload, channel);
        verify(m_MessageFactory, times(1)).createPhysicalLinkResponseMessage(eq(message), 
                eq(PhysicalLinkMessageType.SetPropertyResponse), eq((Message)null));
        ArgumentCaptor<Map> dictCaptor = ArgumentCaptor.forClass(Map.class);
        verify(physLink, times(1)).setProperties(dictCaptor.capture());
        Map<String, Object> capDict = dictCaptor.getValue();
        assertThat(capDict.size(), is(1));
        assertThat((String)capDict.get("AKey"), is("valueA"));
    }
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ Test public void testSetPropertyRequest ( ) throws IOException , IllegalArgumentException , IllegalStateException , FactoryException { UUID uuid = UUID . randomUUID ( ) ; Multitype multi = Multitype . newBuilder ( ) . setStringValue ( "valueA" ) . setType ( Type . STRING ) . build ( ) ; SimpleTypesMapEntry type = SimpleTypesMapEntry . newBuilder ( ) . setKey ( "AKey" ) . setValue ( multi ) . build ( ) ; SetPropertyRequestData request = SetPropertyRequestData . newBuilder ( ) . setUuid ( SharedMessageUtils . convertUUIDToProtoUUID ( uuid ) ) . addProperties ( type ) . build ( ) ; PhysicalLinkNamespace physLinkMessage = PhysicalLinkNamespace . newBuilder ( ) . setType ( PhysicalLinkMessageType . SetPropertyRequest ) . setData ( request . toByteString ( ) ) . build ( ) ; TerraHarvestPayload payload = createPayload ( physLinkMessage ) ; TerraHarvestMessage message = createPhysicalLinkMessage ( physLinkMessage ) ; PhysicalLink physLink = mock ( PhysicalLink . class ) ; when ( physLink . getUuid ( ) ) . thenReturn ( uuid ) ; Map < String , Object > propsToSet = new HashMap < > ( ) ; propsToSet . put ( "AKey" , "" ) ; when ( physLink . getProperties ( ) ) . thenReturn ( propsToSet ) ; List < PhysicalLink > phyLinkList = new ArrayList < PhysicalLink > ( ) ; phyLinkList . add ( physLink ) ; when ( m_CustomCommsService . getPhysicalLinks ( ) ) . thenReturn ( phyLinkList ) ; RemoteChannel channel = mock ( RemoteChannel . class ) ; m_SUT . handleMessage ( message , payload , channel ) ; verify ( m_MessageFactory , times ( 1 ) ) . createPhysicalLinkResponseMessage ( eq ( message ) , eq ( PhysicalLinkMessageType . SetPropertyResponse ) , eq ( ( Message ) null ) ) ; ArgumentCaptor < Map > dictCaptor = ArgumentCaptor . forClass ( Map . class ) ; verify ( physLink , times ( 1 ) ) . setProperties ( dictCaptor . capture ( ) ) ; Map < String , Object > capDict = dictCaptor . getValue ( ) ; assertThat ( capDict . size ( ) , is ( 1 ) ) ; assertThat ( ( String ) capDict . get ( "AKey" ) , is ( "valueA" ) ) ; }
Verify that a property request is properly handled
Verify that a property request is properly handled
// build request //mock necessary objects/actions // mock the channel the message came from