HttpUtils { public static WrappedWebTarget encodeMapQueryParam( WrappedWebTarget target, String prefix, Map<String, ?> queryParam) { if (prefix == null) { prefix = ""; } if (queryParam != null) { for (Map.Entry<String, ?> e : queryParam.entrySet()) { target = encodeMapQueryParamValue(target, prefix + e.getKey(), e.getValue()); } } return target; }  static String encodePathSegment(@Nonnull String pathSegment); static String encodePathSegment(@Nonnull Number pathSegment); static String encodePathSegment(@Nonnull Boolean pathSegment); static String encodePathSegment(@Nonnull Character pathSegment); static String encodePathSegment(@Nonnull UUID pathSegment); static Object attemptEncodeQueryParam(Object queryParam); static WrappedWebTarget encodeMapQueryParam(
            WrappedWebTarget target, String prefix, Map<String, ?> queryParam); static WrappedWebTarget encodeCollectionFormatQueryParam(
            WrappedWebTarget target,
            String queryParamName,
            List<T> values,
            CollectionFormatType collectionFormatType);  }
@Ignore("DEX-1801: Fix Mockito Problem in Release TeamCity Job") @Test public void encodeMapQueryParam_mapOfStringToBoolean() { String prefix = "definedTags Exists."; String keyName1 = "tagMustExist"; String keyName2 = "tagMust NotExist"; Map<String, Boolean> definedTagsExists = ImmutableMap.of(keyName1, true, keyName2, false); WebTarget target = mock(WebTarget.class); when(target.queryParam(anyString(), any())).thenReturn(target); WrappedWebTarget wrapped = new WrappedWebTarget(target); WrappedWebTarget result = HttpUtils.encodeMapQueryParam(wrapped, prefix, definedTagsExists); assertNotNull(result); String prefixEncoded = "definedTags%20Exists."; String keyName2Encoded = "tagMust%20NotExist"; verify(target).queryParam(prefixEncoded + keyName1, true); verify(target).queryParam(prefixEncoded + keyName2Encoded, false); }
@Ignore("DEX-1801: Fix Mockito Problem in Release TeamCity Job") @Test public void attemptEncodeQueryParam_mapOfStringToListOfString() throws IllegalAccessException, NoSuchFieldException { String prefix = "defined Tags."; String keyName1 = "tag1"; String option1a = "option1a"; String option1b = "option1 b"; String keyName2 = "tag 2"; String option2a = "option2a"; String option2b = "option2 b"; Map<String, List<String>> definedTags = ImmutableMap.<String, List<String>>of( keyName1, ImmutableList.of(option1a, option1b), keyName2, ImmutableList.of(option2a, option2b)); WebTarget target = mock(WebTarget.class); when(target.queryParam(anyString(), any())).thenReturn(target); WrappedWebTarget wrapped = new WrappedWebTarget(target); WrappedWebTarget result = HttpUtils.encodeMapQueryParam(wrapped, prefix, definedTags); assertNotNull(result); String prefixEncoded = "defined%20Tags."; String keyName2Encoded = "tag%202"; String option1bEncoded = "option1%20b"; String option2bEncoded = "option2%20b"; verify(target).queryParam(prefixEncoded + keyName1, option1a); verify(target).queryParam(prefixEncoded + keyName1, option1bEncoded); verify(target).queryParam(prefixEncoded + keyName2Encoded, option2a); verify(target).queryParam(prefixEncoded + keyName2Encoded, option2bEncoded); }
@Ignore("DEX-1801: Fix Mockito Problem in Release TeamCity Job") @Test public void attemptEncodeQueryParam_null() { WebTarget target = mock(WebTarget.class); WrappedWebTarget wrapped = new WrappedWebTarget(target); WrappedWebTarget result = HttpUtils.encodeMapQueryParam(wrapped, "prefix", null); assertTrue(result == wrapped); Mockito.verifyNoMoreInteractions(target); }
@Ignore("DEX-1801: Fix Mockito Problem in Release TeamCity Job") @Test public void encodeMapQueryParam_mapOfStringToBoolean_nullPrefix() { String prefix = null; String keyName1 = "tagMustExist"; String keyName2 = "tagMust NotExist"; Map<String, Boolean> definedTagsExists = ImmutableMap.of(keyName1, true, keyName2, false); WebTarget target = mock(WebTarget.class); when(target.queryParam(anyString(), any())).thenReturn(target); WrappedWebTarget wrapped = new WrappedWebTarget(target); WrappedWebTarget result = HttpUtils.encodeMapQueryParam(wrapped, prefix, definedTagsExists); assertNotNull(result); String prefixEncoded = ""; String keyName2Encoded = "tagMust%20NotExist"; verify(target).queryParam(prefixEncoded + keyName1, true); verify(target).queryParam(prefixEncoded + keyName2Encoded, false); }