### Question:
ResponseParser { public static String nonPublicField(final Class givenClass, final Object obj, final Field field) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { String fieldName = null; String fieldValue = null; try { fieldName = URLEncoder.encode(field.getName(), "UTF-8"); String capitalizedField = fieldName.substring(0, 1).toUpperCase( Locale.ENGLISH) + fieldName.substring(1); String getter = field.getType().equals(boolean.class) || field.getType().equals(Boolean.class) ? "is" + capitalizedField : "get" + capitalizedField; fieldValue = URLEncoder.encode(String.valueOf( givenClass.getDeclaredMethod(getter).invoke(obj)), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } assert fieldName != null && fieldValue != null; return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, fieldName + "=" + fieldValue).replace("+", "%20"); } private  ResponseParser(); static String toURLEncoded(final Class givenClass,
            final Object obj); static String publicField(final Object obj, final Field field); static String nonPublicField(final Class givenClass,
            final Object obj, final Field field); static void publicField(final String parameterName,
            final String parameterValue, final Class givenClass,
            final Object obj); static void nonPublicField(final String parameterName,
            final String parameterValue, final Class givenClass,
            final Object obj); static Object toObject(final String response,
            final Class givenClass); static String encodeParameter(final String parameterName,
            final String parameterValue);  }### Answer:
@Test public void testNonPublicFields() throws NoSuchFieldException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { RequestToken requestToken = new RequestToken("token", "secret"); Field field = RequestToken.class.getDeclaredField("authorized"); String parameterPair = ResponseParser.nonPublicField(RequestToken.class, requestToken, field); assertEquals(parameterPair, "authorized=false"); field = RequestToken.class.getDeclaredField("requestToken"); parameterPair = ResponseParser.nonPublicField(RequestToken.class, requestToken, field); assertEquals(parameterPair, "request_token=token"); }
@Test public void testNonPublicFieldsObjectCreation() throws IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, UnsupportedEncodingException, NoSuchFieldException { Class aclass = RequestToken.class; RequestToken obj = (RequestToken) aclass.newInstance(); String parameterName = "requestToken"; String parameterValue = "token"; ResponseParser.nonPublicField(parameterName, parameterValue, aclass, obj); assertEquals(obj.getRequestToken(), "token"); assertNull(obj.getTokenSecret()); assertFalse(obj.isAuthorized()); parameterName = "authorized"; parameterValue = "true"; ResponseParser.nonPublicField(parameterName, parameterValue, aclass, obj); assertEquals(obj.getRequestToken(), "token"); assertNull(obj.getTokenSecret()); assertTrue(obj.isAuthorized()); }