### Question:
MasterTaskExecThread extends MasterBaseTaskExecThread { public Boolean existsValidWorkerGroup(String taskInstanceWorkerGroup){ Set<String> workerGroups = zookeeperRegistryCenter.getWorkerGroupDirectly(); if (CollectionUtils.isEmpty(workerGroups)){ return false; } if (!workerGroups.contains(taskInstanceWorkerGroup)){ return false; } Set<String> workers = zookeeperRegistryCenter.getWorkerGroupNodesDirectly(taskInstanceWorkerGroup); if (CollectionUtils.isEmpty(workers)) { return false; } return true; } MasterTaskExecThread(TaskInstance taskInstance); @Override TaskInstance getTaskInstance(); @Override Boolean submitWaitComplete(); Boolean waitTaskQuit(); void pauseTask(); Boolean existsValidWorkerGroup(String taskInstanceWorkerGroup);  }### Answer:
@Test public void testExistsValidWorkerGroup1(){ Mockito.when(zookeeperRegistryCenter.getWorkerGroupDirectly()).thenReturn(Sets.newHashSet()); boolean b = masterTaskExecThread.existsValidWorkerGroup("default"); Assert.assertFalse(b); }
@Test public void testExistsValidWorkerGroup2(){ Set<String> workerGorups = new HashSet<>(); workerGorups.add("test1"); workerGorups.add("test2"); Mockito.when(zookeeperRegistryCenter.getWorkerGroupDirectly()).thenReturn(workerGorups); boolean b = masterTaskExecThread.existsValidWorkerGroup("default"); Assert.assertFalse(b); }
@Test public void testExistsValidWorkerGroup3(){ Set<String> workerGorups = new HashSet<>(); workerGorups.add("test1"); Mockito.when(zookeeperRegistryCenter.getWorkerGroupDirectly()).thenReturn(workerGorups); Mockito.when(zookeeperRegistryCenter.getWorkerGroupNodesDirectly("test1")).thenReturn(workerGorups); boolean b = masterTaskExecThread.existsValidWorkerGroup("test1"); Assert.assertTrue(b); }