chore: adding support for multiple-environment error messages (#26005)

## Description
> Support PR for EE error handling for multiple-environments
- To support the error handling in EE, this PR addresses refactoring of
methods

Fixes https://github.com/appsmithorg/appsmith/issues/25964
Ref: https://github.com/appsmithorg/appsmith-ee/pull/1980
This commit is contained in:
Manish Kumar 2023-08-04 20:39:52 +05:30 committed by GitHub
parent da3fd27cc2
commit cadae671d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -92,8 +92,7 @@ public class DatasourceStorageServiceCEImpl implements DatasourceStorageServiceC
return Mono.just(datasourceStorage);
})
.switchIfEmpty(Mono.error(new AppsmithException(
AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE, datasource.getName())));
.switchIfEmpty(Mono.defer(() -> errorMonoWhenDatasourceStorageNotFound(datasource, environmentId)));
}
@Override
@ -341,4 +340,10 @@ public class DatasourceStorageServiceCEImpl implements DatasourceStorageServiceC
public Mono<String> getEnvironmentNameFromEnvironmentIdForAnalytics(String environmentId) {
return Mono.just(FieldName.UNUSED_ENVIRONMENT_ID);
}
protected Mono<DatasourceStorage> errorMonoWhenDatasourceStorageNotFound(
Datasource datasource, String environmentId) {
return Mono.error(
new AppsmithException(AppsmithError.NO_RESOURCE_FOUND, FieldName.DATASOURCE, datasource.getName()));
}
}

View File

@ -211,9 +211,6 @@ public class DatasourceStorageServiceTest {
String datasourceId = "datasourceForUnsavedStorage";
String environmentIdOne = FieldName.UNUSED_ENVIRONMENT_ID;
Mockito.when(pluginExecutorHelper.getPluginExecutor(Mockito.any()))
.thenReturn(Mono.just(new MockPluginExecutor()));
Datasource datasource = new Datasource();
datasource.setId(datasourceId);