|
|
@@ -11,6 +11,7 @@ import com.malk.benteler.dto.EiamUpdateUserItem;
|
|
|
import com.malk.server.aliwork.YDAuth;
|
|
|
import com.malk.server.aliwork.YDConf;
|
|
|
import com.malk.server.aliwork.YDParam;
|
|
|
+import com.malk.server.common.McException;
|
|
|
import com.malk.service.aliwork.YDClient_Form;
|
|
|
import com.malk.service.aliwork.YDService;
|
|
|
import org.junit.Before;
|
|
|
@@ -120,7 +121,7 @@ public class BentelerYidaSyncServiceTest {
|
|
|
Collections.singletonList("user_1"));
|
|
|
Map<String, Object> formData = new HashMap<>();
|
|
|
formData.put(conf.getUpdateContentFieldId(),
|
|
|
- Collections.singletonList(BentelerYidaFormMapper.UPDATE_PRIMARY_ORG));
|
|
|
+ Collections.singletonList(BentelerYidaFormMapper.REPLACE_PRIMARY_ORG));
|
|
|
formData.put(conf.getUpdateOrganizationalUnitIdFieldId(), "ou_target");
|
|
|
formData.put(conf.getUpdateTableFieldId(), Collections.singletonList(row));
|
|
|
when(ydClientForm.getForm(any(YDAuth.class), anyString(), isNull()))
|
|
|
@@ -140,6 +141,31 @@ public class BentelerYidaSyncServiceTest {
|
|
|
assertEquals("ou_target", items.get(0).getPrimaryOrganizationalUnitId());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void syncUpdate_replaceAndAddDepartment_rejectsBeforeEiamCall() {
|
|
|
+ Map<String, Object> row = new HashMap<>();
|
|
|
+ row.put(conf.getUpdateEmployeeFieldId() + "_id",
|
|
|
+ Collections.singletonList("user_1"));
|
|
|
+ Map<String, Object> formData = new HashMap<>();
|
|
|
+ formData.put(conf.getUpdateContentFieldId(), Arrays.asList(
|
|
|
+ BentelerYidaFormMapper.REPLACE_PRIMARY_ORG,
|
|
|
+ BentelerYidaFormMapper.ADD_ORG));
|
|
|
+ formData.put(conf.getUpdateOrganizationalUnitIdFieldId(), "ou_target");
|
|
|
+ formData.put(conf.getUpdateTableFieldId(), Collections.singletonList(row));
|
|
|
+ when(ydClientForm.getForm(any(YDAuth.class), anyString(), isNull()))
|
|
|
+ .thenReturn(instance(formData));
|
|
|
+
|
|
|
+ try {
|
|
|
+ service.syncUpdate("form_update_conflict");
|
|
|
+ } catch (McException ex) {
|
|
|
+ assertEquals("EIAM_UPDATE_CONTENT_CONFLICT", ex.getCode());
|
|
|
+ assertEquals("替换部门和增加部门不能同时选择", ex.getMessage());
|
|
|
+ verify(eiamLocalService, never()).batchUpdate(any());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ throw new AssertionError("替换部门和增加部门同时选择时应拒绝请求");
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public void syncUpdate_phoneOnly_doesNotRequireOrganizationalUnit() {
|