    @Test
    public void testTransformSensorStringReplacingWithPublicAddressAndPort() throws Exception {

        final AttributeSensor<String> TARGET_HOSTNAME = new BasicAttributeSensor<String>(String.class, "hostname");
        final AttributeSensor<String> OTHER_HOSTNAME = new BasicAttributeSensor<String>(String.class, "otherhostname");
        final AttributeSensor<Integer> TARGET_PORT = new BasicAttributeSensor<Integer>(Integer.class, "target.port");
        final AttributeSensor<String> ENDPOINT = new BasicAttributeSensor<String>(String.class, "endpoint");
        final AttributeSensor<String> PUBLIC_ENDPOINT = new BasicAttributeSensor<String>(String.class, "publicEndpoint");

        AttributeMunger munger = new AttributeMunger(app);

        munger.transformSensorStringReplacingWithPublicAddressAndPort(
                new EntityAndAttribute<String>(app, ENDPOINT),
                Optional.of(new EntityAndAttribute<Integer>(app, TARGET_PORT)),
                ImmutableList.of(TARGET_HOSTNAME, OTHER_HOSTNAME),
                new EntityAndAttribute<String>(app, PUBLIC_ENDPOINT));

        app.sensors().set(TARGET_HOSTNAME, "myprivatehostname");
        app.sensors().set(TARGET_PORT, 1234);
        app.sensors().set(ENDPOINT, "PREFIX://myprivatehostname:1234/POSTFIX");
        app.sensors().set(PUBLIC_ENDPOINT, "mypublichostname:5678");

        EntityAsserts.assertAttributeEqualsEventually(app, ENDPOINT, "PREFIX://mypublichostname:5678/POSTFIX");
    }