### Question:
JournalFolderResolversImpl implements JournalFolderResolvers { @Override public DataFetcher<JournalFolder> createJournalFolderDataFetcher() { return environment -> { long userId = util.getLongArg(environment, "userId", util.getDefaultUserId()); long groupId = util.getLongArg(environment, "groupId"); long parentFolderId = util.getLongArg(environment, "parentFolderId", JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID); String name = util.getStringArg(environment, "name"); String description = util.getStringArg(environment, "description"); ServiceContext serviceContext = new ServiceContext(); return journalFolderLocalService.addFolder( userId, groupId, parentFolderId, name, description, serviceContext); }; }  @Reference(unbind = "-") void setJournalFolderLocalService(JournalFolderLocalService journalFolderLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<JournalFolder>> getJournalFoldersDataFetcher(); @Override DataFetcher<CompletableFuture<JournalFolder>> getJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> createJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> updateJournalFolderDataFetcher(); @Override DataFetcher<JournalFolder> deleteJournalFolderDataFetcher();  }### Answer:
@Test public void createJournalFolderDataFetcher_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("userId", USER_ID); arguments.put("groupId", GROUP_ID); arguments.put("parentFolderId", PARENT_FOLDER_ID); arguments.put("name", NAME); arguments.put("description", DESCRIPTION); DataFetchingEnvironment environment = getTestEnvironment(arguments); JournalFolder expectedResult = mock(JournalFolder.class); expectedResult.setUserId(USER_ID); expectedResult.setFolderId(FOLDER_ID); expectedResult.setGroupId(GROUP_ID); expectedResult.setParentFolderId(PARENT_FOLDER_ID); expectedResult.setName(NAME); expectedResult.setDescription(DESCRIPTION); useMockGraphQLUtil(environment, USER_ID, true); when(localService.addFolder(eq(USER_ID), eq(GROUP_ID), eq(PARENT_FOLDER_ID), eq(NAME), eq(DESCRIPTION), any(ServiceContext.class))) .thenReturn(expectedResult); JournalFolder result = resolvers.createJournalFolderDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void createJournalFolderDataFetcher_without_user_id_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("groupId", GROUP_ID); arguments.put("parentFolderId", PARENT_FOLDER_ID); arguments.put("name", NAME); arguments.put("description", DESCRIPTION); DataFetchingEnvironment environment = getTestEnvironment(arguments); JournalFolder expectedResult = mock(JournalFolder.class); expectedResult.setUserId(DEFAULT_USER_ID); expectedResult.setFolderId(FOLDER_ID); expectedResult.setGroupId(GROUP_ID); expectedResult.setParentFolderId(PARENT_FOLDER_ID); expectedResult.setName(NAME); expectedResult.setDescription(DESCRIPTION); useMockGraphQLUtil(environment, DEFAULT_USER_ID, true); when(localService.addFolder(eq(DEFAULT_USER_ID), eq(GROUP_ID), eq(PARENT_FOLDER_ID), eq(NAME), eq(DESCRIPTION), any(ServiceContext.class))) .thenReturn(expectedResult); JournalFolder result = resolvers.createJournalFolderDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = PortalException.class) public void createJournalFolderDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, DEFAULT_USER_ID, false); when(localService.addFolder(anyLong(), anyLong(), anyLong(), anyString(), anyString(), any(ServiceContext.class))) .thenThrow(PortalException.class); JournalFolder result = resolvers.createJournalFolderDataFetcher() .get(environment); assertNull(result); }