Browse Source

[Feature][dolphinscheduler-api] Return domain object after creating success (#8825)

Co-authored-by: ouyangyewei <yewei.oyyw@alibaba-inc.com>
3.0.0/version-upgrade
ouyangyewei 3 years ago committed by GitHub
parent
commit
5fa1c4e7e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
  2. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java
  3. 1
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
  4. 1
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java

7
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java

@ -157,7 +157,12 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
// insert // insert
try { try {
int insert = alertGroupMapper.insert(alertGroup); int insert = alertGroupMapper.insert(alertGroup);
putMsg(result, insert > 0 ? Status.SUCCESS : Status.CREATE_ALERT_GROUP_ERROR); if (insert > 0) {
result.put(Constants.DATA_LIST, alertGroup);
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.CREATE_ALERT_GROUP_ERROR);
}
} catch (DuplicateKeyException ex) { } catch (DuplicateKeyException ex) {
logger.error("Create alert group error.", ex); logger.error("Create alert group error.", ex);
putMsg(result, Status.ALERT_GROUP_EXIST); putMsg(result, Status.ALERT_GROUP_EXIST);

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java

@ -91,8 +91,8 @@ public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements A
} }
int i = alertPluginInstanceMapper.insert(alertPluginInstance); int i = alertPluginInstanceMapper.insert(alertPluginInstance);
if (i > 0) { if (i > 0) {
result.put(Constants.DATA_LIST, alertPluginInstance);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }

1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java

@ -110,6 +110,7 @@ public class AlertGroupServiceTest {
result = alertGroupService.createAlertgroup(user, groupName, groupName, null); result = alertGroupService.createAlertgroup(user, groupName, groupName, null);
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
Assert.assertNotNull(result.get(Constants.DATA_LIST));
} }
@Test @Test

1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java

@ -163,6 +163,7 @@ public class AlertPluginInstanceServiceTest {
Mockito.when(alertPluginInstanceMapper.insert(Mockito.any())).thenReturn(1); Mockito.when(alertPluginInstanceMapper.insert(Mockito.any())).thenReturn(1);
result = alertPluginInstanceService.create(user, 1, "test1", uiParams); result = alertPluginInstanceService.create(user, 1, "test1", uiParams);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
Assert.assertNotNull(result.get(Constants.DATA_LIST));
} }
@Test @Test

Loading…
Cancel
Save