use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmTenantLifecycleServiceUnitTest method testServiceCallFail.
@Test
public void testServiceCallFail() {
XmEntity xmEntity = getEntity();
context.put(LepXmEntityMsConstants.BINDING_KEY_SERVICES, Collections.singletonList(SERVICE_NAME));
TenantClient client = new FailClient();
tenantClients.add(client);
xmTenantLifecycleService.changeState(xmEntity, EntityState.ACTIVE.name(), context);
assertEquals(1, xmEntity.getData().size());
assertEquals(false, ((ServiceInfo) ((Map) xmEntity.getData().get(SERVICE_NAME)).get("create")).isSuccess());
assertEquals(EXEC_ERROR, ((ServiceInfo) ((Map) xmEntity.getData().get(SERVICE_NAME)).get("create")).getErrorMessage());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmTenantLifecycleServiceUnitTest method testServiceCallPass.
@Test
public void testServiceCallPass() {
XmEntity xmEntity = getEntity();
Map<String, Object> serviceInfo = new HashMap<>();
Map<String, Object> action = new HashMap<>();
serviceInfo.put("create", action);
action.put(SUCCESS_NAME, true);
xmEntity.getData().put(SERVICE_NAME, serviceInfo);
context.put(LepXmEntityMsConstants.BINDING_KEY_SERVICES, Collections.singletonList(SERVICE_NAME));
TenantClient client = new FailClient();
tenantClients.add(client);
xmTenantLifecycleService.changeState(xmEntity, EntityState.ACTIVE.name(), context);
assertEquals(1, xmEntity.getData().size());
assertEquals(true, ((Map) ((Map) xmEntity.getData().get(SERVICE_NAME)).get("create")).get(SUCCESS_NAME));
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmTenantLifecycleServiceUnitTest method testServiceCallSuccessWithNullContext.
@Test
public void testServiceCallSuccessWithNullContext() {
when(applicationProperties.getTenantCreateServiceList()).thenReturn(Collections.singletonList(SERVICE_NAME));
XmEntity xmEntity = getEntity();
TenantClient client = new SuccessClient();
tenantClients.add(client);
xmTenantLifecycleService.changeState(xmEntity, EntityState.ACTIVE.name(), null);
assertEquals(1, xmEntity.getData().size());
assertEquals(true, ((ServiceInfo) ((Map) xmEntity.getData().get(SERVICE_NAME)).get("create")).isSuccess());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmTenantLifecycleServiceUnitTest method testNoContext.
@Test
public void testNoContext() {
XmEntity xmEntity = getEntity();
xmTenantLifecycleService.changeState(xmEntity, EntityState.ACTIVE.name(), context);
assertEquals(0, xmEntity.getData().size());
}
use of com.icthh.xm.ms.entity.domain.XmEntity in project xm-ms-entity by xm-online.
the class XmTenantLifecycleServiceUnitTest method testServiceCallSuccess.
@Test
public void testServiceCallSuccess() {
XmEntity xmEntity = getEntity();
context.put(LepXmEntityMsConstants.BINDING_KEY_SERVICES, Collections.singletonList(SERVICE_NAME));
TenantClient client = new SuccessClient();
tenantClients.add(client);
xmTenantLifecycleService.changeState(xmEntity, EntityState.ACTIVE.name(), context);
assertEquals(1, xmEntity.getData().size());
assertEquals(true, ((ServiceInfo) ((Map) xmEntity.getData().get(SERVICE_NAME)).get("create")).isSuccess());
}
Aggregations