### Question:
ExpandoColumnResolversImpl implements ExpandoColumnResolvers { @Override public DataFetcher<ExpandoColumn> updateExpandoColumnDataFetcher() { return environment -> { long columnId = util.getLongArg(environment, "columnId"); String name = util.getStringArg(environment, "name"); int type = util.getIntArg(environment, "type", ExpandoColumnConstants.STRING); return expandoColumnLocalService.updateColumn( columnId, name, type, null); }; }  @Reference(unbind = "-") void setExpandoColumnLocalService(ExpandoColumnLocalService expandoColumnLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoColumn>> getExpandoColumnsDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoColumn>> getExpandoColumnDataFetcher(); @Override DataFetcher<ExpandoColumn> createExpandoColumnDataFetcher(); @Override DataFetcher<ExpandoColumn> updateExpandoColumnDataFetcher(); @Override DataFetcher<ExpandoColumn> deleteExpandoColumnDataFetcher();  }### Answer:
@Test public void updateExpandoColumnDataFetcher_should_return_updated_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("columnId", COLUMN_ID); arguments.put("name", NAME); arguments.put("type", TYPE); DataFetchingEnvironment environment = getTestEnvironment(arguments); ExpandoColumn expectedResult = mock(ExpandoColumn.class); expectedResult.setColumnId(COLUMN_ID); expectedResult.setName(NAME); expectedResult.setType(TYPE); useMockGraphQLUtil(environment, true); when(localService.updateColumn(eq(COLUMN_ID), eq(NAME), eq(TYPE), any())) .thenReturn(expectedResult); ExpandoColumn result = resolvers.updateExpandoColumnDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchColumnException.class) public void updateExpandoColumnDataFetcher_with_no_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("name", NAME); arguments.put("type", TYPE); DataFetchingEnvironment environment = getTestEnvironment(arguments); useMockGraphQLUtil(environment, true); when(graphQLUtil.getLongArg(eq(environment), eq("columnId"))) .thenReturn(0L); when(localService.updateColumn(eq(0L), eq(NAME), eq(TYPE), any())) .thenThrow(NoSuchColumnException.class); ExpandoColumn result = resolvers.updateExpandoColumnDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchColumnException.class) public void updateExpandoColumnDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("columnId", 789456L); arguments.put("name", NAME); arguments.put("type", TYPE); DataFetchingEnvironment environment = getTestEnvironment(arguments); useMockGraphQLUtil(environment, true); when(graphQLUtil.getLongArg(eq(environment), eq("columnId"))) .thenReturn(789456L); when(localService.updateColumn(eq(789456L), eq(NAME), eq(TYPE), any())) .thenThrow(NoSuchColumnException.class); ExpandoColumn result = resolvers.updateExpandoColumnDataFetcher() .get(environment); assertNull(result); }
@Test(expected = PortalException.class) public void updateExpandoColumnDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("columnId"))) .thenReturn(0L); when(localService.updateColumn(anyLong(), anyString(), anyInt(), any())) .thenThrow(PortalException.class); ExpandoColumn result = resolvers.updateExpandoColumnDataFetcher() .get(environment); assertNull(result); }