use of org.hisp.dhis.webapi.service.ContextService in project dhis2-core by dhis2.
the class DataElementOperandControllerTest method setUp.
@BeforeEach
public void setUp() {
ContextService contextService = new DefaultContextService();
QueryService _queryService = new DefaultQueryService(new DefaultJpaQueryParser(schemaService), new DefaultQueryPlanner(schemaService), mock(JpaCriteriaQueryEngine.class), new InMemoryQueryEngine<>(schemaService, mock(AclService.class), currentUserService));
// Use "spy" on queryService, because we want a partial mock: we only
// want to
// mock the method "count"
queryService = spy(_queryService);
// Controller under test
final DataElementOperandController controller = new DataElementOperandController(manager, queryService, fieldFilterService, linkService, contextService, schemaService, dataElementCategoryService);
// Set custom Node Message converter //
NodeService nodeService = new DefaultNodeService();
Jackson2JsonNodeSerializer serializer = new Jackson2JsonNodeSerializer(staticJsonMapper());
ReflectionTestUtils.setField(nodeService, "nodeSerializers", Lists.newArrayList(serializer));
ReflectionTestUtils.invokeMethod(nodeService, "init");
JsonMessageConverter jsonMessageConverter = new JsonMessageConverter(nodeService, Compression.NONE);
mockMvc = MockMvcBuilders.standaloneSetup(controller).setMessageConverters(jsonMessageConverter).build();
// End mockmvc setup
when(schemaService.getDynamicSchema(DataElementOperand.class)).thenReturn(new Schema(DataElementOperand.class, "", ""));
when(currentUserService.getCurrentUser()).thenReturn(rnd.nextObject(User.class));
}
Aggregations