use of com.icthh.xm.ms.entity.service.FunctionContextService in project xm-ms-entity by xm-online.
the class FunctionServiceImplUnitTest method setUp.
@Before
public void setUp() {
xmEntitySpecService = Mockito.mock(XmEntitySpecService.class);
xmEntityService = Mockito.mock(XmEntityService.class);
functionExecutorService = Mockito.mock(FunctionExecutorService.class);
functionContextService = Mockito.mock(FunctionContextService.class);
dynamicPermissionCheckService = Mockito.mock(DynamicPermissionCheckService.class);
xmEntityTenantConfigService = Mockito.mock(XmEntityTenantConfigService.class);
jsonValidationService = spy(new JsonValidationService(new ObjectMapper()));
functionService = new FunctionServiceImpl(xmEntitySpecService, xmEntityService, functionExecutorService, functionContextService, dynamicPermissionCheckService, jsonValidationService, xmEntityTenantConfigService);
xmEntityTenantConfig = new XmEntityTenantConfig();
when(xmEntityTenantConfigService.getXmEntityTenantConfig()).thenReturn(xmEntityTenantConfig);
}
use of com.icthh.xm.ms.entity.service.FunctionContextService in project xm-ms-entity by xm-online.
the class FunctionServiceImplUnitTest method executeWithSaveContext.
/**
* Test in progress
*/
@Test
public void executeWithSaveContext() {
FunctionSpec spec = getFunctionSpec(Boolean.TRUE);
Map<String, Object> context = Maps.newHashMap();
context.put("key1", "val1");
Map<String, Object> data = Maps.newHashMap();
data.put("KEY1", "VAL1");
when(xmEntitySpecService.findFunction(functionName)).thenReturn(Optional.of(spec));
when(functionExecutorService.execute(functionName, context, null)).thenReturn(data);
when(functionContextService.save(any())).thenAnswer((Answer<FunctionContext>) invocation -> {
Object[] args = invocation.getArguments();
return (FunctionContext) args[0];
});
FunctionContext fc = functionService.execute(functionName, context, null);
assertThat(fc.getTypeKey()).isEqualTo(functionName);
assertThat(fc.getKey()).contains(functionName);
assertThat(fc.getData().keySet()).containsSequence(data.keySet().toArray(new String[0]));
verify(functionContextService, Mockito.times(1)).save(any());
}
Aggregations