Skip to content

Commit

Permalink
mock cluster status, to enable test again (missing status bean cased …
Browse files Browse the repository at this point in the history
…replacement character to kick in)

FYI @skayliu, referring to your question in #565
  • Loading branch information
nitram509 committed Nov 18, 2023
1 parent 731ff50 commit 8012adb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.zeebe.monitor.rest;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import io.camunda.zeebe.client.api.response.Topology;
import io.zeebe.monitor.repository.ElementInstanceRepository;
import io.zeebe.monitor.repository.ErrorRepository;
import io.zeebe.monitor.repository.HazelcastConfigRepository;
Expand All @@ -12,6 +16,8 @@
import io.zeebe.monitor.repository.TimerRepository;
import io.zeebe.monitor.repository.VariableRepository;
import io.zeebe.monitor.zeebe.ZeebeHazelcastService;
import io.zeebe.monitor.zeebe.status.ClusterStatus;
import io.zeebe.monitor.zeebe.status.ZeebeStatusKeeper;
import io.zeebe.monitor.zeebe.status.ZeebeStatusUpdateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
Expand All @@ -35,12 +41,12 @@
@ActiveProfiles("junittest")
public abstract class AbstractViewOrResourceTest {

@LocalServerPort
protected int port;
@LocalServerPort protected int port;
@Autowired protected MockMvc mockMvc;
@Autowired protected TestRestTemplate restTemplate;
@Autowired protected InstancesViewController instancesViewController;
@Autowired protected InstancesVariableListController instancesVariableListController;
@Autowired protected ZeebeStatusKeeper zeebeStatusKeeper;

@MockBean protected ZeebeStatusUpdateService zeebeStatusUpdateService;
@MockBean protected HazelcastConfigRepository hazelcastConfigRepository;
Expand All @@ -55,4 +61,12 @@ public abstract class AbstractViewOrResourceTest {
@MockBean protected TimerRepository timerRepository;
@MockBean protected VariableRepository variableRepository;
@MockBean protected ErrorRepository errorRepository;

protected void mockCLusterStatusForViews() {
final Topology topologyMock = mock(Topology.class);
ClusterStatus clusterStatus = new ClusterStatus();
when(topologyMock.getGatewayVersion()).thenReturn("v9.9.9");
clusterStatus.setTopology(topologyMock);
zeebeStatusKeeper.setStatus(clusterStatus);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public class ProcessesViewControllerTest extends AbstractViewOrResourceTest {

@BeforeEach
public void setUp() throws Exception {
public void setUp() {
when(processRepository.findAll(any(Pageable.class))).thenReturn(Page.empty());
mockCLusterStatusForViews();
}

@Test
Expand Down Expand Up @@ -59,12 +59,10 @@ public void index_page_contains_whitelabeling_css() throws Exception {
"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/test-custom.css\"/>")));
}

@Disabled
@Test
public void status_page_all_DTO_fields_in_template_can_be_resolved() throws Exception {
mockMvc
.perform(get("/views/processes"))
.andExpect(content().string(not(containsString(REPLACEMENT_CHARACTER_QUESTIONMARK))));
}

}

0 comments on commit 8012adb

Please sign in to comment.