Search in sources :

Example 1 with XmEntityServiceImpl

use of com.icthh.xm.ms.entity.service.impl.XmEntityServiceImpl in project xm-ms-entity by xm-online.

the class XmEntityResourceIntTest method setup.

@SneakyThrows
@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    when(authContextHolder.getContext()).thenReturn(context);
    when(context.getUserKey()).thenReturn(Optional.of("userKey"));
    when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(MOCKED_START_DATE);
    when(startUpdateDateGenerationStrategy.generateUpdateDate()).thenReturn(MOCKED_UPDATE_DATE);
    XmEntityServiceImpl xmEntityServiceImpl = new XmEntityServiceImpl(xmEntitySpecService, xmEntityRepository, xmEntitySearchRepository, lifeCycleService, xmEntityPermittedRepository, profileService, linkService, storageService, attachmentService, xmEntityPermittedSearchRepository, startUpdateDateGenerationStrategy, authContextHolder);
    xmEntityServiceImpl.setSelf(xmEntityServiceImpl);
    this.xmEntityServiceImpl = xmEntityServiceImpl;
    lepManager.beginThreadContext(ctx -> {
        ctx.setValue(THREAD_CONTEXT_KEY_TENANT_CONTEXT, tenantContextHolder.getContext());
        ctx.setValue(THREAD_CONTEXT_KEY_AUTH_CONTEXT, authContextHolder.getContext());
    });
    XmEntityResource resourceMock = mock(XmEntityResource.class);
    when(resourceMock.createXmEntity(any())).thenReturn(ResponseEntity.created(new URI("")).build());
    XmEntityResource xmEntityResourceMock = new XmEntityResource(xmEntityServiceImpl, profileService, profileEventProducer, functionService, tenantService, resourceMock);
    this.restXmEntityMockMvc = MockMvcBuilders.standaloneSetup(xmEntityResourceMock).setCustomArgumentResolvers(pageableArgumentResolver).setControllerAdvice(exceptionTranslator).setValidator(validator).setMessageConverters(jacksonMessageConverter).build();
    xmEntity = createEntity(em);
}
Also used : URI(java.net.URI) XmEntityServiceImpl(com.icthh.xm.ms.entity.service.impl.XmEntityServiceImpl) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 2 with XmEntityServiceImpl

use of com.icthh.xm.ms.entity.service.impl.XmEntityServiceImpl in project xm-ms-entity by xm-online.

the class XmEntityResourceExtendedIntTest method setup.

@Before
public void setup() {
    log.info("Init setup");
    // xmEntitySearchRepository.deleteAll();
    MockitoAnnotations.initMocks(this);
    when(authContextHolder.getContext()).thenReturn(context);
    when(context.getUserKey()).thenReturn(Optional.of("userKey"));
    when(startUpdateDateGenerationStrategy.generateStartDate()).thenReturn(MOCKED_START_DATE);
    when(startUpdateDateGenerationStrategy.generateUpdateDate()).thenReturn(MOCKED_UPDATE_DATE);
    XmEntityServiceImpl xmEntityService = new XmEntityServiceImpl(xmEntitySpecService, xmEntityRepository, xmEntitySearchRepository, lifeCycleService, xmEntityPermittedRepository, profileService, linkService, storageService, attachmentService, xmEntityPermittedSearchRepository, startUpdateDateGenerationStrategy, authContextHolder);
    xmEntityService.setSelf(xmEntityService);
    this.xmEntityService = xmEntityService;
    lepManager.beginThreadContext(ctx -> {
        ctx.setValue(THREAD_CONTEXT_KEY_TENANT_CONTEXT, tenantContextHolder.getContext());
        ctx.setValue(THREAD_CONTEXT_KEY_AUTH_CONTEXT, authContextHolder.getContext());
    });
    EventResource eventResourceMock = new EventResource(eventService, eventResource);
    XmEntityResource xmEntityResourceMock = new XmEntityResource(xmEntityService, profileService, profileEventProducer, functionService, tenantService, xmEntityResource);
    this.restXmEntityMockMvc = MockMvcBuilders.standaloneSetup(xmEntityResourceMock, new CalendarResource(calendarService, calendarResource), eventResourceMock).setCustomArgumentResolvers(pageableArgumentResolver).setControllerAdvice(exceptionTranslator).setValidator(validator).setMessageConverters(jacksonMessageConverter).build();
    xmEntityIncoming = createEntityComplexIncoming(em);
}
Also used : XmEntityServiceImpl(com.icthh.xm.ms.entity.service.impl.XmEntityServiceImpl) Before(org.junit.Before)

Aggregations

XmEntityServiceImpl (com.icthh.xm.ms.entity.service.impl.XmEntityServiceImpl)2 Before (org.junit.Before)2 URI (java.net.URI)1 SneakyThrows (lombok.SneakyThrows)1