Skip to content

Commit 49b9214

Browse files
authored
Merge pull request #330 from entando/ESB-966
ESB-966 - Fix SystemControllerTest to stub both jpcontentscheduler and jpcontentworkflow plugins
2 parents 58e3136 + d416142 commit 49b9214

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

engine/src/test/java/org/entando/entando/web/system/SystemControllerTest.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
@ExtendWith(MockitoExtension.class)
3838
class SystemControllerTest extends AbstractControllerTest {
3939

40-
final String CONTENT_SCHEDULER_CODE="jpcontentscheduler";
40+
static final String CONTENT_SCHEDULER_CODE = "jpcontentscheduler";
41+
static final String CONTENT_WORKFLOW_CODE = "jpcontentworkflow";
4142

4243
@Mock
4344
private ComponentManager componentManager;
@@ -57,23 +58,35 @@ public void setUp() throws Exception {
5758

5859
@Test
5960
void testWithContentSchedulerInstalled() throws Exception {
60-
testWithContentSchedulerInstalled(true);
61+
testWithPlugins(true, false);
6162
}
6263

6364
@Test
6465
void testWithContentSchedulerNotInstalled() throws Exception {
65-
testWithContentSchedulerInstalled(false);
66+
testWithPlugins(false, false);
6667
}
6768

68-
private void testWithContentSchedulerInstalled(boolean installed) throws Exception {
69+
@Test
70+
void testWithContentWorkflowInstalled() throws Exception {
71+
testWithPlugins(false, true);
72+
}
73+
74+
@Test
75+
void testWithAllPluginsInstalled() throws Exception {
76+
testWithPlugins(true, true);
77+
}
78+
79+
private void testWithPlugins(boolean schedulerInstalled, boolean workflowInstalled) throws Exception {
6980
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
7081
String accessToken = mockOAuthInterceptor(user);
71-
when(componentManager.isComponentInstalled(CONTENT_SCHEDULER_CODE)).thenReturn(installed);
82+
when(componentManager.isComponentInstalled(CONTENT_SCHEDULER_CODE)).thenReturn(schedulerInstalled);
83+
when(componentManager.isComponentInstalled(CONTENT_WORKFLOW_CODE)).thenReturn(workflowInstalled);
7284
ResultActions result = mockMvc.perform(
7385
get("/system/report")
7486
.contentType(MediaType.APPLICATION_JSON_VALUE)
7587
.header("Authorization", "Bearer " + accessToken));
7688
result.andExpect(status().isOk())
77-
.andExpect(jsonPath("$.payload.contentSchedulerPluginInstalled", is(installed)));
89+
.andExpect(jsonPath("$.payload.contentSchedulerPluginInstalled", is(schedulerInstalled)))
90+
.andExpect(jsonPath("$.payload.contentWorkFlowPluginInstalled", is(workflowInstalled)));
7891
}
7992
}

0 commit comments

Comments
 (0)