### Question:
ToolGroupApiService { @PreAuthorize("hasRole('ADMIN') OR (hasRole('TOOL_GROUP_MANAGER') AND " + "hasPermission(#group.registryId, 'com.epam.pipeline.entity.pipeline.DockerRegistry', 'WRITE'))") public ToolGroup create(final ToolGroup group) { return toolGroupManager.create(group); }  @PreAuthorize("hasRole('ADMIN') OR (hasRole('TOOL_GROUP_MANAGER') AND " + "hasPermission(#group.registryId, 'com.epam.pipeline.entity.pipeline.DockerRegistry', 'WRITE'))") ToolGroup create(final ToolGroup group); @PreAuthorize("hasRole('ADMIN') OR hasPermission(#group, 'WRITE')") ToolGroup update(final ToolGroup group); @PostFilter("hasRole('ADMIN') OR hasPermission(filterObject, 'READ')") @AclMaskList List<ToolGroup> loadByRegistryId(Long registryId); @PostFilter("hasRole('ADMIN') OR hasPermission(filterObject, 'READ')") @AclMaskList List<ToolGroup> loadByRegistryNameOrId(String registry); @AclTree ToolGroup load(Long groupId); @AclTree ToolGroupWithIssues loadToolsWithIssuesCount(Long groupId); @AclTree ToolGroup loadByNameOrId(String groupId); ToolGroup loadPrivate(Long registryId); @PreAuthorize("hasRole('ADMIN') OR @grantPermissionManager.createPrivateToolGroupPermission(#registryId)") ToolGroup createPrivate(Long registryId); @PreAuthorize("hasRole('ADMIN') or (hasRole('TOOL_GROUP_MANAGER') AND " + "@grantPermissionManager.toolGroupPermission(#id, 'WRITE'))") ToolGroup delete(String id); @PreAuthorize("hasRole('ADMIN') or (hasRole('TOOL_GROUP_MANAGER') AND " + "@grantPermissionManager.toolGroupChildPermission(#id, 'WRITE'))") ToolGroup deleteForce(String id);  }### Answer:
@Test(expected = AccessDeniedException.class) @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class) @WithMockUser(username = TEST_USER2) public void testCreateToolInOtherPrivateGroupFails() { Tool tool = ToolApiServiceTest.generateTool(); tool.setToolGroupId(existingGroup.getId()); tool.setToolGroup(existingGroup.getName()); toolApiService.create(tool); }