File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
bigtop-manager-server/src/test/java/org/apache/bigtop/manager/server/command/task Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments