public static NamingSelector newMetadataSelector(Map<String, String> metadata) {
        return newMetadataSelector(metadata, false);
    }
@Test
    public void testNewMetadataSelector2() {
        Instance ins1 = new Instance();
        ins1.addMetadata("a", "1");
        ins1.addMetadata("c", "3");
        Instance ins2 = new Instance();
        ins2.addMetadata("b", "2");
        Instance ins3 = new Instance();
        ins3.addMetadata("c", "3");
        
        NamingContext namingContext = mock(NamingContext.class);
        when(namingContext.getInstances()).thenReturn(Arrays.asList(ins1, ins2, ins3));
        
        NamingSelector metadataSelector = NamingSelectorFactory.newMetadataSelector(new HashMap() {
            {
                put("a", "1");
                put("b", "2");
            }
        }, true);
        List<Instance> result = metadataSelector.select(namingContext).getResult();
        
        assertEquals(2, result.size());
        assertEquals(ins1, result.get(0));
        assertEquals(ins2, result.get(1));
    }