fix(test): FlowDefAdminService 两个测试跟随 de332d1 的 save 8 参签名与 FlwInstanceRepository 注入(B1 漏提交,HEAD 测试编译红修复)
build / build-push (push) Successful in 56s
build / build-push (push) Successful in 56s
This commit is contained in:
@@ -48,6 +48,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
mock(FlwRouterRepository.class),
|
mock(FlwRouterRepository.class),
|
||||||
mock(com.yunhai.flowcenter.repository.FlwCallbackRegRepository.class),
|
mock(com.yunhai.flowcenter.repository.FlwCallbackRegRepository.class),
|
||||||
appRepository,
|
appRepository,
|
||||||
|
mock(com.yunhai.flowcenter.repository.FlwInstanceRepository.class),
|
||||||
mock(com.yunhai.flowcenter.service.FlowDeptAdminService.class),
|
mock(com.yunhai.flowcenter.service.FlowDeptAdminService.class),
|
||||||
mock(FlowEngine.class),
|
mock(FlowEngine.class),
|
||||||
new ObjectMapper());
|
new ObjectMapper());
|
||||||
@@ -71,7 +72,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
@Test
|
@Test
|
||||||
void 新建_永远新开流程线_版本从1起() {
|
void 新建_永远新开流程线_版本从1起() {
|
||||||
ArgumentCaptor<FlwDef> cap = ArgumentCaptor.forClass(FlwDef.class);
|
ArgumentCaptor<FlwDef> cap = ArgumentCaptor.forClass(FlwDef.class);
|
||||||
FlwDef saved = service.save(SCH, null, "work-leave", "请假", JSON, null, "notice");
|
FlwDef saved = service.save(SCH, null, "work-leave", "请假", JSON, null, "notice", null);
|
||||||
verify(defRepository).save(cap.capture());
|
verify(defRepository).save(cap.capture());
|
||||||
assertEquals(cap.getValue(), saved);
|
assertEquals(cap.getValue(), saved);
|
||||||
assertEquals(1, saved.getVersion());
|
assertEquals(1, saved.getVersion());
|
||||||
@@ -82,8 +83,8 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void 连续新建同编码_各得独立流程线() {
|
void 连续新建同编码_各得独立流程线() {
|
||||||
FlwDef a = service.save(SCH, null, "work-leave", "产假", JSON, null, "notice");
|
FlwDef a = service.save(SCH, null, "work-leave", "产假", JSON, null, "notice", null);
|
||||||
FlwDef b = service.save(SCH, null, "work-leave", "丧假", JSON, null, "notice");
|
FlwDef b = service.save(SCH, null, "work-leave", "丧假", JSON, null, "notice", null);
|
||||||
assertEquals(1, a.getVersion());
|
assertEquals(1, a.getVersion());
|
||||||
assertEquals(1, b.getVersion());
|
assertEquals(1, b.getVersion());
|
||||||
assertNotEquals(a.getFlowGuid(), b.getFlowGuid());
|
assertNotEquals(a.getFlowGuid(), b.getFlowGuid());
|
||||||
@@ -97,7 +98,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
.thenReturn(Optional.of(base));
|
.thenReturn(Optional.of(base));
|
||||||
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(6);
|
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(6);
|
||||||
|
|
||||||
FlwDef saved = service.save(SCH, null, "work-leave", "请假", JSON, "G", null);
|
FlwDef saved = service.save(SCH, null, "work-leave", "请假", JSON, "G", null, null);
|
||||||
|
|
||||||
assertEquals("G", saved.getFlowGuid());
|
assertEquals("G", saved.getFlowGuid());
|
||||||
assertEquals(7, saved.getVersion());
|
assertEquals(7, saved.getVersion());
|
||||||
@@ -112,7 +113,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.findById(9L)).thenReturn(Optional.of(published));
|
when(defRepository.findById(9L)).thenReturn(Optional.of(published));
|
||||||
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
||||||
|
|
||||||
FlwDef saved = service.save(SCH, 9L, "work-leave", "请假", JSON, null, null);
|
FlwDef saved = service.save(SCH, 9L, "work-leave", "请假", JSON, null, null, null);
|
||||||
|
|
||||||
assertEquals("G", saved.getFlowGuid());
|
assertEquals("G", saved.getFlowGuid());
|
||||||
assertEquals(5, saved.getVersion());
|
assertEquals(5, saved.getVersion());
|
||||||
@@ -126,7 +127,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
draft.setAppKey("notice");
|
draft.setAppKey("notice");
|
||||||
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
||||||
|
|
||||||
FlwDef saved = service.save(SCH, 9L, "work-leave", "新名字", JSON, null, null);
|
FlwDef saved = service.save(SCH, 9L, "work-leave", "新名字", JSON, null, null, null);
|
||||||
|
|
||||||
assertSame(draft, saved);
|
assertSame(draft, saved);
|
||||||
assertEquals("新名字", saved.getName());
|
assertEquals("新名字", saved.getName());
|
||||||
@@ -137,19 +138,19 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "GX"))
|
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "GX"))
|
||||||
.thenReturn(Optional.empty());
|
.thenReturn(Optional.empty());
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, null, "work-leave", "请假", JSON, "GX", null));
|
() -> service.save(SCH, null, "work-leave", "请假", JSON, "GX", null, null));
|
||||||
assertTrue(e.getMessage().contains("baseGuid"));
|
assertTrue(e.getMessage().contains("baseGuid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void 新建_归属应用直接落库_空白规整生效() {
|
void 新建_归属应用直接落库_空白规整生效() {
|
||||||
assertEquals("notice", service.save(SCH, null, "work-leave", "请假", JSON, null, " notice ").getAppKey());
|
assertEquals("notice", service.save(SCH, null, "work-leave", "请假", JSON, null, " notice ", null).getAppKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void 新建_appKey不传_必填被拦() {
|
void 新建_appKey不传_必填被拦() {
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, null, "work-leave", "请假", JSON, null, " "));
|
() -> service.save(SCH, null, "work-leave", "请假", JSON, null, " ", null));
|
||||||
assertTrue(e.getMessage().contains("归属应用必填"));
|
assertTrue(e.getMessage().contains("归属应用必填"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,8 +161,8 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "G")).thenReturn(Optional.of(base));
|
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "G")).thenReturn(Optional.of(base));
|
||||||
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
||||||
|
|
||||||
assertEquals("notice", service.save(SCH, null, "work-leave", "请假", JSON, "G", null).getAppKey());
|
assertEquals("notice", service.save(SCH, null, "work-leave", "请假", JSON, "G", null, null).getAppKey());
|
||||||
assertEquals("crm", service.save(SCH, null, "work-leave", "请假", JSON, "G", "crm").getAppKey());
|
assertEquals("crm", service.save(SCH, null, "work-leave", "请假", JSON, "G", "crm", null).getAppKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -172,7 +173,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
||||||
|
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, null, "work-leave", "请假", JSON, "G", null));
|
() -> service.save(SCH, null, "work-leave", "请假", JSON, "G", null, null));
|
||||||
assertTrue(e.getMessage().contains("归属应用必填"));
|
assertTrue(e.getMessage().contains("归属应用必填"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,8 +183,8 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
draft.setAppKey("notice");
|
draft.setAppKey("notice");
|
||||||
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
||||||
|
|
||||||
assertEquals("notice", service.save(SCH, 9L, "work-leave", "请假", JSON, null, null).getAppKey());
|
assertEquals("notice", service.save(SCH, 9L, "work-leave", "请假", JSON, null, null, null).getAppKey());
|
||||||
assertEquals("crm", service.save(SCH, 9L, "work-leave", "请假", JSON, null, "crm").getAppKey());
|
assertEquals("crm", service.save(SCH, 9L, "work-leave", "请假", JSON, null, "crm", null).getAppKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -192,7 +193,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
when(defRepository.findById(9L)).thenReturn(Optional.of(draft));
|
||||||
|
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, 9L, "work-leave", "请假", JSON, null, null));
|
() -> service.save(SCH, 9L, "work-leave", "请假", JSON, null, null, null));
|
||||||
assertTrue(e.getMessage().contains("归属应用必填"));
|
assertTrue(e.getMessage().contains("归属应用必填"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +206,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.save(any())).thenThrow(new DataIntegrityViolationException("dup"));
|
when(defRepository.save(any())).thenThrow(new DataIntegrityViolationException("dup"));
|
||||||
|
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, 9L, "work-leave", "请假", JSON, null, null));
|
() -> service.save(SCH, 9L, "work-leave", "请假", JSON, null, null, null));
|
||||||
assertTrue(e.getMessage().contains("保存冲突"));
|
assertTrue(e.getMessage().contains("保存冲突"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +214,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
void appKey不在启用白名单_保存被拦() {
|
void appKey不在启用白名单_保存被拦() {
|
||||||
when(appRepository.isEnabledApp(SCH, "999999")).thenReturn(false);
|
when(appRepository.isEnabledApp(SCH, "999999")).thenReturn(false);
|
||||||
BizException e = assertThrows(BizException.class,
|
BizException e = assertThrows(BizException.class,
|
||||||
() -> service.save(SCH, null, "work-leave", "请假", JSON, null, "999999"));
|
() -> service.save(SCH, null, "work-leave", "请假", JSON, null, "999999", null));
|
||||||
assertTrue(e.getMessage().contains("应用设置"));
|
assertTrue(e.getMessage().contains("应用设置"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ class FlowDefAdminServiceSaveTest {
|
|||||||
when(defRepository.findById(9L)).thenReturn(Optional.of(published));
|
when(defRepository.findById(9L)).thenReturn(Optional.of(published));
|
||||||
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
when(defRepository.maxVersionByGuid(SCH, "G")).thenReturn(4);
|
||||||
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "G")).thenReturn(Optional.empty());
|
when(defRepository.findFirstBySchIdAndFlowGuidOrderByVersionDesc(SCH, "G")).thenReturn(Optional.empty());
|
||||||
FlwDef saved = service.save(SCH, 9L, "work-leave", "请假", JSON, null, null);
|
FlwDef saved = service.save(SCH, 9L, "work-leave", "请假", JSON, null, null, null);
|
||||||
org.mockito.Mockito.verify(appRepository, org.mockito.Mockito.never()).isEnabledApp(any(), any());
|
org.mockito.Mockito.verify(appRepository, org.mockito.Mockito.never()).isEnabledApp(any(), any());
|
||||||
assertEquals("notice", saved.getAppKey());
|
assertEquals("notice", saved.getAppKey());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class FlowDefAdminServiceUpdateMetaTest {
|
|||||||
mock(FlwRouterRepository.class),
|
mock(FlwRouterRepository.class),
|
||||||
mock(com.yunhai.flowcenter.repository.FlwCallbackRegRepository.class),
|
mock(com.yunhai.flowcenter.repository.FlwCallbackRegRepository.class),
|
||||||
appRepository,
|
appRepository,
|
||||||
|
mock(com.yunhai.flowcenter.repository.FlwInstanceRepository.class),
|
||||||
mock(com.yunhai.flowcenter.service.FlowDeptAdminService.class),
|
mock(com.yunhai.flowcenter.service.FlowDeptAdminService.class),
|
||||||
mock(FlowEngine.class),
|
mock(FlowEngine.class),
|
||||||
new ObjectMapper());
|
new ObjectMapper());
|
||||||
|
|||||||
Reference in New Issue
Block a user