Skip to content

Commit 171016b

Browse files
authored
Update ComponentStartTaskTest.java
1 parent bf1f9bf commit 171016b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/command/task/ComponentStartTaskTest.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ public void setUp() {
9191
ComponentDTO componentDTO = new ComponentDTO();
9292
componentDTO.setName("TestComponentName");
9393
componentDTO.setDisplayName("TestComponentDisplayName");
94-
stackUtilsMocked.when(() -> StackUtils.getComponentDTO("TestComponentName")).thenReturn(componentDTO);
95-
94+
stackUtilsMocked
95+
.when(() -> StackUtils.getComponentDTO("TestComponentName"))
96+
.thenReturn(componentDTO);
97+
9698
StackDTO stackDTO = new StackDTO();
9799
stackDTO.setStackName("test-stack");
98100
stackDTO.setStackVersion("1.0.0");
99-
stackUtilsMocked.when(() -> StackUtils.getServiceStack("TestServiceName")).thenReturn(stackDTO);
101+
stackUtilsMocked
102+
.when(() -> StackUtils.getServiceStack("TestServiceName"))
103+
.thenReturn(stackDTO);
100104

101105
componentStartTask = mock(ComponentStartTask.class);
102106

@@ -142,6 +146,12 @@ public void testGetCommand() {
142146
public void testOnSuccess() {
143147
doCallRealMethod().when(componentStartTask).onSuccess();
144148

149+
// Mock hostDao.findByHostname to avoid Host not found exception
150+
HostPO hostPO = new HostPO();
151+
hostPO.setId(1L);
152+
hostPO.setHostname("TestHostname");
153+
when(hostDao.findByHostname("TestHostname")).thenReturn(hostPO);
154+
145155
List<ComponentPO> componentPOS = new ArrayList<>();
146156
ComponentPO existing = new ComponentPO();
147157
existing.setId(1L);

0 commit comments

Comments
 (0)