Search in sources :

Example 6 with XmEntity

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());
}
Also used : TenantClient(com.icthh.xm.ms.entity.web.client.tenant.TenantClient) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with XmEntity

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));
}
Also used : HashMap(java.util.HashMap) TenantClient(com.icthh.xm.ms.entity.web.client.tenant.TenantClient) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 8 with XmEntity

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());
}
Also used : TenantClient(com.icthh.xm.ms.entity.web.client.tenant.TenantClient) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 9 with XmEntity

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());
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Test(org.junit.Test)

Example 10 with XmEntity

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());
}
Also used : TenantClient(com.icthh.xm.ms.entity.web.client.tenant.TenantClient) XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)102 Test (org.junit.Test)60 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)46 Transactional (org.springframework.transaction.annotation.Transactional)32 Link (com.icthh.xm.ms.entity.domain.Link)22 Tag (com.icthh.xm.ms.entity.domain.Tag)10 ConstraintViolation (javax.validation.ConstraintViolation)9 WithMockUser (org.springframework.security.test.context.support.WithMockUser)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 SneakyThrows (lombok.SneakyThrows)8 Attachment (com.icthh.xm.ms.entity.domain.Attachment)7 Location (com.icthh.xm.ms.entity.domain.Location)7 lombok.val (lombok.val)7 Calendar (com.icthh.xm.ms.entity.domain.Calendar)6 Profile (com.icthh.xm.ms.entity.domain.Profile)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Rating (com.icthh.xm.ms.entity.domain.Rating)5 Timed (com.codahale.metrics.annotation.Timed)4