MessagingUtils { public static String buildTopicNameForAgent( Instance instance ) { Instance scopedInstance = InstanceHelpers.findScopedInstance( instance ); return buildTopicNameForAgent( InstanceHelpers.computeInstancePath( scopedInstance )); } private  MessagingUtils(); static String buildTopicNameForAgent( Instance instance ); static String buildTopicNameForAgent( String scopedInstancePath ); static String escapeInstancePath( String instancePath ); static String buildId(
			RecipientKind ownerKind,
			String domain,
			String applicationName,
			String scopedInstancePath );  }
@Test public void testBuildRoutingKeyForAgent_String() { Assert.assertEquals( "machine.root", MessagingUtils.buildTopicNameForAgent( "root" )); Assert.assertEquals( "machine.root", MessagingUtils.buildTopicNameForAgent("/root")); Assert.assertEquals( "machine.root", MessagingUtils.buildTopicNameForAgent( "/root/" )); Assert.assertEquals( "machine.root.docker", MessagingUtils.buildTopicNameForAgent( "/root/docker" )); Assert.assertNotSame( MessagingUtils.buildTopicNameForAgent( "root1" ), MessagingUtils.buildTopicNameForAgent( "root2" )); }
@Test public void testBuildRoutingKeyForAgent_Instance() { Instance inst = new Instance( "my-root" ); Assert.assertNotNull( MessagingUtils.buildTopicNameForAgent( inst )); Assert.assertEquals( MessagingUtils.buildTopicNameForAgent( inst ), MessagingUtils.buildTopicNameForAgent( inst.getName())); Instance childInstance = new Instance( "child" ); InstanceHelpers.insertChild( inst, childInstance ); Assert.assertEquals( MessagingUtils.buildTopicNameForAgent( childInstance ), MessagingUtils.buildTopicNameForAgent( inst )); }