### Question:
GsonFactory { public static Gson create() { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.excludeFieldsWithoutExposeAnnotation(); gsonBuilder.disableHtmlEscaping(); gsonBuilder.registerTypeAdapterFactory(new ReportLookupTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new InputControlTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new ReportExecutionRequestOptionsFactory()); gsonBuilder.registerTypeAdapterFactory(new DashboardComponentTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new JobSourceParamsWrapperTypeAdapterFactory()); return gsonBuilder.create(); }  static Gson create();  }### Answer:
@Test public void shouldEnableGsonExposeAnnotationField() throws Exception { GsonBuilder gsonBuilder = PowerMockito.mock(GsonBuilder.class); whenNew(GsonBuilder.class).withNoArguments().thenReturn(gsonBuilder); GsonFactory.create(); verify(gsonBuilder, times(1)).excludeFieldsWithoutExposeAnnotation(); }
@Test public void shouldDisableHtmlEscaping() throws Exception { GsonBuilder gsonBuilder = PowerMockito.mock(GsonBuilder.class); whenNew(GsonBuilder.class).withNoArguments().thenReturn(gsonBuilder); GsonFactory.create(); verify(gsonBuilder, times(1)).disableHtmlEscaping(); }
@Test public void shouldCreateInstanceOfGson() { Gson gson = GsonFactory.create(); assertThat(gson, Is.is(notNullValue())); }
@Test public void shouldModifyReportExecutionParametersField() throws Exception { ReportExecutionRequestOptions options = ReportExecutionRequestOptions.newRequest("/my/uri"); options.withParameters(Collections.singletonList(new ReportParameter("key", Collections.singleton("value")))); Gson gson = GsonFactory.create(); assertThat(gson.toJson(options), is("{\"reportUnitUri\":\"/my/uri\",\"parameters\":{\"reportParameter\":[{\"name\":\"key\",\"value\":[\"value\"]}]}}")); }
@Test public void should_parse_only_input_controls_from_dashboard_components() throws Exception { Gson gson = GsonFactory.create(); DashboardComponentCollection components = gson.fromJson(mComponents.asString(), DashboardComponentCollection.class); assertThat(components.getInputControlComponents() , is(not(empty()))); }
@Test public void should_deserialize_form_with_custom_rule() throws Exception { Gson gson = GsonFactory.create(); JobFormEntity entity = gson.fromJson(mGetJobResponse.asString(), JobFormEntity.class); assertThat(entity , is(notNullValue())); }