use of com.icthh.xm.commons.tenant.TenantContext in project xm-ms-entity by xm-online.
the class XmEntitySpecServiceUnitTest method init.
@Before
@SneakyThrows
public void init() {
TenantContext tenantContext = mock(TenantContext.class);
when(tenantContext.getTenantKey()).thenReturn(Optional.of(TenantKey.valueOf(TENANT)));
tenantContextHolder = mock(TenantContextHolder.class);
when(tenantContextHolder.getContext()).thenReturn(tenantContext);
ApplicationProperties ap = new ApplicationProperties();
ap.setSpecificationPathPattern(URL);
xmEntitySpecService = createXmEntitySpecService(ap, tenantContextHolder);
}
use of com.icthh.xm.commons.tenant.TenantContext in project xm-ms-entity by xm-online.
the class TenantInterceptorIntTest method testSuccess.
@Test
// TODO fix when security test will be implemented
@Ignore
public void testSuccess() throws Exception {
when(auth.getDetails()).thenReturn(details);
when(details.getDecodedDetails()).thenReturn(ImmutableMap.builder().put("tenant", "xm").build());
lepManager.beginThreadContext(threadContext -> {
TenantContext tenantContext = mock(TenantContext.class);
when(tenantContext.getTenantKey()).thenReturn(Optional.of(TenantKey.valueOf("xm")));
threadContext.setValue(THREAD_CONTEXT_KEY_TENANT_CONTEXT, tenantContext);
threadContext.setValue(THREAD_CONTEXT_KEY_AUTH_CONTEXT, mock(XmAuthenticationContext.class));
});
try {
// Create the XmEntity
restXmEntityMockMvc.perform(get("/api/xm-entities")).andExpect(status().isOk());
} finally {
lepManager.endThreadContext();
}
}
Aggregations