### Question:
MBeanSelector { public static MBeanSelector create(Map<String, Object> map) { return new MBeanSelector(map); } private  MBeanSelector(Map<String, Object> map); private  MBeanSelector(MBeanSelector first, MBeanSelector second); static MBeanSelector create(Map<String, Object> map); String getPrintableRequest(); String getRequest(); String getUrl(Protocol protocol, String host, int port); QueryType getQueryType();  }### Answer:
@Test public void queryFieldsMatchValues() { MBeanSelector selector = MBeanSelector.create( ImmutableMap.of(MBeanSelector.VALUES, EXPECTED_COMPONENT_VALUES)); assertThat(querySpec(selector), hasJsonPath("$.fields").withValues(EXPECTED_COMPONENT_VALUES)); }
@Test public void whenKeySpecified_isIncludedInQueryFields() { MBeanSelector selector = MBeanSelector.create( ImmutableMap.of(MBeanSelector.VALUES, EXPECTED_COMPONENT_VALUES, MBeanSelector.KEY, "name")); assertThat(querySpec(selector), hasJsonPath("$.fields").includingValues("name")); }
@Test public void whenTypeSpecified_standardFieldTypeIsIncludedInQueryFields() { MBeanSelector selector = MBeanSelector.create( ImmutableMap.of(MBeanSelector.VALUES, EXPECTED_COMPONENT_VALUES, MBeanSelector.TYPE, "OneTypeOnly")); assertThat(querySpec(selector), hasJsonPath("$.fields").includingValues(MBeanSelector.TYPE_FIELD_NAME)); }
@Test public void whenMapHasNestedElements_pathIncludesChildren() { MBeanSelector selector = MBeanSelector.create(ImmutableMap.of("servlets", ImmutableMap.of(MBeanSelector.VALUES, new String[] {"first", "second"}))); assertThat(querySpec(selector), hasJsonPath("$.children.servlets.fields").withValues("first", "second")); }