chore: enabled autocommit (#41255)

## Description
> [!TIP]  
> _Add a TL;DR when the description is longer than 500 words or
extremely technical (helps the content, marketing, and DevRel team)._
>
> _Please also include relevant motivation and context. List any
dependencies that are required for this change. Add links to Notion,
Figma or any other documents that might be relevant to the PR._


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Git"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/17945463792>
> Commit: 02dea2de752e6171fa3e4cefd8650b7fcf9b332f
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=17945463792&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Tue, 23 Sep 2025 12:56:31 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Auto-commit now accepts author name and email so commits reflect the
initiating user.
  * Auto-commit processing can run asynchronously in the background.

* **Improvements**
* Auto-commit flows will fall back to generated author info when a
stored Git profile is unavailable.
* Controller now delegates auto-commit to a central service for
consistent responses.
  * Enhanced logging for clearer Git operation traceability.

* **Tests**
* Updated and un-skipped end-to-end and unit tests covering auto-commit
paths.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Manish Kumar 2025-09-24 11:01:43 +05:30 committed by GitHub
parent 903d952854
commit d5ee69016a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 154 additions and 105 deletions

View File

@ -26,7 +26,7 @@ describe(
],
},
function () {
it.skip("Check if autocommit progress bar is visible and network requests are properly called", function () {
it("Check if autocommit progress bar is visible and network requests are properly called", function () {
agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
wsName = "GitAC-" + uid;

View File

@ -18,4 +18,8 @@ public @interface GitRoute {
ArtifactType artifactType();
GitRouteOperation operation();
String authorName() default "";
String authorEmail() default "";
}

View File

@ -142,6 +142,8 @@ public class GitRouteAspect {
// Intermediate Inputs
private String fieldValue;
private String authorName;
private String authorEmail;
// Tasks
private Artifact artifact;
@ -229,6 +231,14 @@ public class GitRouteAspect {
return execute(ctx);
}
String authorName = extractFieldValue(joinPoint, gitRoute.authorName());
String authorEmail = extractFieldValue(joinPoint, gitRoute.authorEmail());
if (StringUtils.hasText(authorName) && StringUtils.hasText(authorEmail)) {
ctx.setAuthorEmail(authorEmail);
ctx.setAuthorName(authorName);
}
String fieldValue = extractFieldValue(joinPoint, gitRoute.fieldName());
ctx.setFieldValue(fieldValue);
return run(ctx, State.ROUTE_FILTER).flatMap(unused -> {
@ -267,14 +277,15 @@ public class GitRouteAspect {
Outcome.SUCCESS.name(),
result,
duration);
} else {
log.info(
"Operation : {}, State {} : {}, Time: {}ms",
ctx.getGitRoute().operation(),
current,
Outcome.SUCCESS.name(),
duration);
}
log.info(
"Operation : {}, State {} : {}, Time: {}ms",
ctx.getGitRoute().operation(),
current,
Outcome.SUCCESS.name(),
duration);
return run(ctx, config.next(Outcome.SUCCESS));
})
.onErrorResume(e -> {
@ -460,10 +471,23 @@ public class GitRouteAspect {
* @return Mono emitting the Git profile, or error if not configured
*/
private Mono<GitProfile> gitProfile(Context ctx) {
return gitProfileUtils
.getGitProfileForUser(ctx.getFieldValue())
Mono<GitProfile> alternativeGitProfileMono = Mono.defer(() -> Mono.justOrEmpty(getProfileFromArgs(ctx)))
.switchIfEmpty(Mono.error(new AppsmithException(
AppsmithError.INVALID_GIT_CONFIGURATION, "Git profile is not configured")));
return gitProfileUtils.getGitProfileForUser(ctx.getFieldValue()).switchIfEmpty(alternativeGitProfileMono);
}
private GitProfile getProfileFromArgs(Context ctx) {
if (!StringUtils.hasText(ctx.getAuthorEmail()) || !StringUtils.hasText(ctx.getAuthorName())) {
return null;
}
GitProfile gitProfile = new GitProfile();
gitProfile.setAuthorName(ctx.getAuthorName());
gitProfile.setAuthorEmail(ctx.getAuthorEmail());
gitProfile.setUseGlobalProfile(Boolean.TRUE);
return gitProfile;
}
/**

View File

@ -1,3 +0,0 @@
package com.appsmith.server.git.autocommit;
public interface AutoCommitEventHandler extends AutoCommitEventHandlerCE {}

View File

@ -0,0 +1,3 @@
package com.appsmith.server.git.autocommit;
public interface AutoCommitSolution extends AutoCommitSolutionCE {}

View File

@ -3,10 +3,10 @@ package com.appsmith.server.git.autocommit;
import com.appsmith.server.events.AutoCommitEvent;
import reactor.core.publisher.Mono;
public interface AutoCommitEventHandlerCE {
void publish(AutoCommitEvent autoCommitEvent);
public interface AutoCommitSolutionCE {
void handle(AutoCommitEvent event);
Mono<Boolean> startApplicationAutoCommit(
String baseArtifactId, String authorName, String authorEmail, AutoCommitEvent event);
Mono<Boolean> autoCommitDSLMigration(AutoCommitEvent autoCommitEvent);

View File

@ -6,6 +6,7 @@ import com.appsmith.external.git.constants.GitConstants.GitCommandConstants;
import com.appsmith.external.git.constants.ce.RefType;
import com.appsmith.external.git.handler.FSGitHandler;
import com.appsmith.external.git.models.GitResourceType;
import com.appsmith.server.annotations.GitRoute;
import com.appsmith.server.configurations.ProjectProperties;
import com.appsmith.server.constants.ArtifactType;
import com.appsmith.server.constants.FieldName;
@ -18,6 +19,7 @@ import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.exceptions.AppsmithError;
import com.appsmith.server.exceptions.AppsmithException;
import com.appsmith.server.git.GitRedisUtils;
import com.appsmith.server.git.constants.GitRouteOperation;
import com.appsmith.server.git.dtos.ArtifactJsonTransformationDTO;
import com.appsmith.server.git.resolver.GitArtifactHelperResolver;
import com.appsmith.server.helpers.CollectionUtils;
@ -29,9 +31,6 @@ import com.appsmith.server.services.AnalyticsService;
import com.appsmith.server.services.GitArtifactHelper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
@ -51,8 +50,7 @@ import static java.lang.Boolean.TRUE;
@RequiredArgsConstructor
@Slf4j
public class AutoCommitEventHandlerCEImpl implements AutoCommitEventHandlerCE {
private final ApplicationEventPublisher applicationEventPublisher;
public class AutoCommitSolutionCEImpl implements AutoCommitSolutionCE {
private final GitRedisUtils gitRedisUtils;
private final RedisUtils redisUtils;
private final DSLMigrationUtils dslMigrationUtils;
@ -66,16 +64,15 @@ public class AutoCommitEventHandlerCEImpl implements AutoCommitEventHandlerCE {
"System generated commit, to support new features in Appsmith %s";
@Override
public void publish(AutoCommitEvent autoCommitEvent) {
applicationEventPublisher.publishEvent(autoCommitEvent);
log.info("published event for auto commit: {}", autoCommitEvent);
}
@Async
@EventListener
@Override
public void handle(AutoCommitEvent event) {
log.info("received event for auto commit: {}", event);
@GitRoute(
artifactType = ArtifactType.APPLICATION,
operation = GitRouteOperation.AUTO_COMMIT_SOLUTION,
fieldName = "baseArtifactId",
authorEmail = "authorEmail",
authorName = "authorName")
public Mono<Boolean> startApplicationAutoCommit(
String baseArtifactId, String authorName, String authorEmail, AutoCommitEvent event) {
log.info("Starting auto-commit process for event: {}", event);
Mono<Boolean> autocommitMigration;
if (Boolean.TRUE.equals(event.getIsServerSideEvent())) {
autocommitMigration = this.autoCommitServerMigration(event);
@ -83,13 +80,7 @@ public class AutoCommitEventHandlerCEImpl implements AutoCommitEventHandlerCE {
autocommitMigration = this.autoCommitDSLMigration(event);
}
autocommitMigration
.subscribeOn(Schedulers.boundedElastic())
.subscribe(
result -> log.info(
"Auto-commit completed successfully for application: {}", event.getApplicationId()),
error -> log.error(
"Error during auto-commit for application: {}", event.getApplicationId(), error));
return autocommitMigration.subscribeOn(Schedulers.boundedElastic());
}
private <T> Mono<T> setProgress(T result, String applicationId, int progress) {

View File

@ -8,14 +8,12 @@ import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.DSLMigrationUtils;
import com.appsmith.server.helpers.RedisUtils;
import com.appsmith.server.services.AnalyticsService;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Component;
@Component
public class AutoCommitEventHandlerImpl extends AutoCommitEventHandlerCEImpl implements AutoCommitEventHandler {
public class AutoCommitSolutionImpl extends AutoCommitSolutionCEImpl implements AutoCommitSolution {
public AutoCommitEventHandlerImpl(
ApplicationEventPublisher applicationEventPublisher,
public AutoCommitSolutionImpl(
GitRedisUtils gitRedisUtils,
RedisUtils redisUtils,
DSLMigrationUtils dslMigrationUtils,
@ -25,7 +23,6 @@ public class AutoCommitEventHandlerImpl extends AutoCommitEventHandlerCEImpl imp
ProjectProperties projectProperties,
AnalyticsService analyticsService) {
super(
applicationEventPublisher,
gitRedisUtils,
redisUtils,
dslMigrationUtils,

View File

@ -0,0 +1,10 @@
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.events.AutoCommitEvent;
public interface AutoCommitAsyncEventManager {
void publishAsyncEvent(AutoCommitEvent autoCommitEvent);
void autoCommitPublishEventListener(AutoCommitEvent event);
}

View File

@ -0,0 +1,45 @@
package com.appsmith.server.git.autocommit.helpers;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.git.autocommit.AutoCommitSolution;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import reactor.core.scheduler.Schedulers;
@Component
@Slf4j
@RequiredArgsConstructor
public class AutoCommitAsyncEventManagerImpl implements AutoCommitAsyncEventManager {
private final ApplicationEventPublisher applicationEventPublisher;
private final AutoCommitSolution autoCommitSolution;
@Override
public void publishAsyncEvent(AutoCommitEvent autoCommitEvent) {
log.info("published event for auto commit: {}", autoCommitEvent);
applicationEventPublisher.publishEvent(autoCommitEvent);
}
@Async
@EventListener
@Override
public void autoCommitPublishEventListener(AutoCommitEvent event) {
log.info("received event for auto commit: {}", event);
String baseArtifactId = event.getApplicationId();
String authorName = event.getAuthorName();
String authorEmail = event.getAuthorEmail();
autoCommitSolution
.startApplicationAutoCommit(baseArtifactId, authorName, authorEmail, event)
.subscribeOn(Schedulers.boundedElastic())
.subscribe(
result -> log.info(
"Auto-commit completed successfully for application: {}", event.getApplicationId()),
error -> log.error(
"Error during auto-commit for application: {}", event.getApplicationId(), error));
}
}

View File

@ -8,7 +8,6 @@ import com.appsmith.server.domains.GitProfile;
import com.appsmith.server.dtos.AutoCommitResponseDTO;
import com.appsmith.server.dtos.AutoCommitTriggerDTO;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.git.autocommit.AutoCommitEventHandler;
import com.appsmith.server.git.central.CentralGitService;
import com.appsmith.server.git.central.GitType;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
@ -30,7 +29,7 @@ import static com.appsmith.server.dtos.AutoCommitResponseDTO.AutoCommitResponse.
@Service
public class GitAutoCommitHelperImpl implements GitAutoCommitHelper {
private final GitPrivateRepoHelper gitPrivateRepoHelper;
private final AutoCommitEventHandler autoCommitEventHandler;
private final AutoCommitAsyncEventManager autoCommitAsyncEventManager;
private final UserDataService userDataService;
private final ApplicationService applicationService;
private final ApplicationPermission applicationPermission;
@ -39,14 +38,14 @@ public class GitAutoCommitHelperImpl implements GitAutoCommitHelper {
public GitAutoCommitHelperImpl(
GitPrivateRepoHelper gitPrivateRepoHelper,
AutoCommitEventHandler autoCommitEventHandler,
AutoCommitAsyncEventManager autoCommitAsyncEventManager,
UserDataService userDataService,
ApplicationService applicationService,
ApplicationPermission applicationPermission,
RedisUtils redisUtils,
@Lazy CentralGitService centralGitService) {
this.gitPrivateRepoHelper = gitPrivateRepoHelper;
this.autoCommitEventHandler = autoCommitEventHandler;
this.autoCommitAsyncEventManager = autoCommitAsyncEventManager;
this.userDataService = userDataService;
this.applicationService = applicationService;
this.applicationPermission = applicationPermission;
@ -217,7 +216,7 @@ public class GitAutoCommitHelperImpl implements GitAutoCommitHelper {
}
// it's a synchronous call, no need to return anything
autoCommitEventHandler.publish(autoCommitEvent);
autoCommitAsyncEventManager.publishAsyncEvent(autoCommitEvent);
return Boolean.TRUE;
})
.defaultIfEmpty(Boolean.FALSE)

View File

@ -23,6 +23,7 @@ public enum GitRouteOperation {
DISCARD_CHANGES(true),
LIST_REFS(true),
AUTO_COMMIT(true),
AUTO_COMMIT_SOLUTION(true),
// whitelisted ones

View File

@ -15,7 +15,6 @@ import com.appsmith.server.domains.Artifact;
import com.appsmith.server.domains.GitArtifactMetadata;
import com.appsmith.server.domains.GitAuth;
import com.appsmith.server.dtos.AutoCommitResponseDTO;
import com.appsmith.server.dtos.AutoCommitResponseDTO.AutoCommitResponse;
import com.appsmith.server.dtos.BranchProtectionRequestDTO;
import com.appsmith.server.dtos.GitAuthDTO;
import com.appsmith.server.dtos.GitConnectDTO;
@ -289,12 +288,9 @@ public class GitApplicationControllerCE {
artifactType = ArtifactType.APPLICATION,
operation = GitRouteOperation.AUTO_COMMIT)
public Mono<ResponseDTO<AutoCommitResponseDTO>> autoCommitApplication(@PathVariable String branchedApplicationId) {
// disabling autocommit till in-memory git has been incorporated in the auto-commit
AutoCommitResponseDTO autoCommitResponseDTO = new AutoCommitResponseDTO();
autoCommitResponseDTO.setAutoCommitResponse(AutoCommitResponse.IDLE);
autoCommitResponseDTO.setProgress(0);
return Mono.just(autoCommitResponseDTO).map(data -> new ResponseDTO<>(HttpStatus.OK, data));
return autoCommitService
.autoCommitApplication(branchedApplicationId)
.map(data -> new ResponseDTO<>(HttpStatus.OK, data));
}
@JsonView(Views.Public.class)

View File

@ -70,19 +70,11 @@ public class RedisUtils {
return redisOperations.opsForValue().delete(key);
}
@Deprecated
public Mono<Boolean> hasKey(String key) {
if (gitServiceConfig.isGitInMemory()) {
return Mono.just(false);
}
return redisOperations.hasKey(key);
}
@Deprecated
public Mono<Boolean> startAutoCommit(String defaultApplicationId, String branchName) {
if (gitServiceConfig.isGitInMemory()) {
return Mono.just(true);
}
String key = String.format(AUTO_COMMIT_KEY_FORMAT, defaultApplicationId);
return redisOperations.hasKey(key).flatMap(isKeyPresent -> {
if (Boolean.TRUE.equals(isKeyPresent)) {
@ -102,20 +94,12 @@ public class RedisUtils {
return redisOperations.opsForValue().get(key).map(Integer::valueOf);
}
@Deprecated
public Mono<Boolean> finishAutoCommit(String defaultApplicationId) {
if (gitServiceConfig.isGitInMemory()) {
return Mono.just(true);
}
String key = String.format(AUTO_COMMIT_KEY_FORMAT, defaultApplicationId);
return redisOperations.opsForValue().delete(key);
}
@Deprecated
public Mono<String> getRunningAutoCommitBranchName(String defaultApplicationId) {
if (gitServiceConfig.isGitInMemory()) {
return Mono.empty();
}
String key = String.format(AUTO_COMMIT_KEY_FORMAT, defaultApplicationId);
return redisOperations.hasKey(key).flatMap(hasKey -> {
if (hasKey) {
@ -131,11 +115,7 @@ public class RedisUtils {
* This would be required for whenever any attribute related to sessions becomes invalid at a systemic level.
* Use with caution, every user will be logged out.
*/
@Deprecated
public Mono<Void> deleteAllSessionsIncludingCurrentUser() {
if (gitServiceConfig.isGitInMemory()) {
return Mono.empty();
}
AtomicInteger deletedKeysCount = new AtomicInteger(0);
return redisOperations

View File

@ -50,7 +50,7 @@ import java.util.List;
import static com.appsmith.external.git.constants.GitConstants.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.server.exceptions.AppsmithError.GIT_MERGE_FAILED_LOCAL_CHANGES;
import static com.appsmith.server.git.autocommit.AutoCommitEventHandlerImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.autocommit.AutoCommitSolutionImpl.AUTO_COMMIT_MSG_FORMAT;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;

View File

@ -53,7 +53,7 @@ import java.util.List;
import static com.appsmith.external.git.constants.GitConstants.DEFAULT_COMMIT_MESSAGE;
import static com.appsmith.external.git.constants.GitConstants.EMPTY_COMMIT_ERROR_MESSAGE;
import static com.appsmith.server.exceptions.AppsmithError.GIT_MERGE_FAILED_LOCAL_CHANGES;
import static com.appsmith.server.git.autocommit.AutoCommitEventHandlerImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.autocommit.AutoCommitSolutionImpl.AUTO_COMMIT_MSG_FORMAT;
import static org.assertj.core.api.Assertions.assertThat;
/**

View File

@ -12,8 +12,8 @@ import com.appsmith.server.dtos.ApplicationImportDTO;
import com.appsmith.server.dtos.ApplicationJson;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.exports.internal.ExportService;
import com.appsmith.server.git.autocommit.AutoCommitEventHandler;
import com.appsmith.server.git.autocommit.AutoCommitEventHandlerImpl;
import com.appsmith.server.git.autocommit.AutoCommitSolution;
import com.appsmith.server.git.autocommit.AutoCommitSolutionImpl;
import com.appsmith.server.git.resolver.GitArtifactHelperResolver;
import com.appsmith.server.helpers.CommonGitFileUtils;
import com.appsmith.server.helpers.DSLMigrationUtils;
@ -62,7 +62,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
import static com.appsmith.server.constants.ArtifactType.APPLICATION;
import static com.appsmith.server.git.autocommit.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.autocommit.AutoCommitSolutionCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@ -124,7 +124,7 @@ public class ServerSchemaMigrationEnforcerTest {
@MockBean
PluginExecutorHelper pluginExecutorHelper;
AutoCommitEventHandler autoCommitEventHandler;
AutoCommitSolution autoCommitSolution;
@Autowired
ProjectProperties projectProperties;
@ -395,8 +395,7 @@ public class ServerSchemaMigrationEnforcerTest {
public void autocommitMigration_WhenServerVersionIsBehindDiffOccursAnd_CommitSuccess()
throws URISyntaxException, IOException, GitAPIException {
autoCommitEventHandler = new AutoCommitEventHandlerImpl(
applicationEventPublisher,
autoCommitSolution = new AutoCommitSolutionImpl(
gitRedisUtils,
redisUtils,
dslMigrationUtils,
@ -425,7 +424,7 @@ public class ServerSchemaMigrationEnforcerTest {
gitFileSystemTestHelper.setupGitRepository(autoCommitEvent, applicationJson);
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {

View File

@ -4,6 +4,7 @@ import com.appsmith.external.dtos.GitLogDTO;
import com.appsmith.external.git.constants.ce.RefType;
import com.appsmith.external.git.handler.FSGitHandler;
import com.appsmith.external.helpers.AppsmithBeanUtils;
import com.appsmith.git.configurations.GitServiceConfig;
import com.appsmith.server.acl.AclPermission;
import com.appsmith.server.applications.base.ApplicationService;
import com.appsmith.server.domains.Application;
@ -54,7 +55,7 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import static com.appsmith.server.git.autocommit.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.autocommit.AutoCommitSolutionCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;
@ -109,6 +110,9 @@ public class AutoCommitServiceTest {
@SpyBean
JsonSchemaMigration jsonSchemaMigration;
@SpyBean
GitServiceConfig gitServiceConfig;
Application testApplication;
Path baseRepoSuffix;
@ -252,6 +256,8 @@ public class AutoCommitServiceTest {
AppsmithBeanUtils.copyNewFieldValuesIntoOldObject(applicationJson, applicationJson1);
applicationJson1.setServerSchemaVersion(jsonSchemaVersions.getServerVersion() + 1);
doReturn(FALSE).when(gitServiceConfig).isGitInMemory();
doReturn(Mono.just(applicationJson1))
.when(jsonSchemaMigration)
.migrateApplicationJsonToLatestSchema(
@ -309,6 +315,8 @@ public class AutoCommitServiceTest {
ApplicationJson applicationJson =
gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource(APP_JSON_NAME));
doReturn(FALSE).when(gitServiceConfig).isGitInMemory();
int pageDSLNumber = applicationJson
.getPageList()
.get(0)

View File

@ -35,7 +35,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.test.annotation.DirtiesContext;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@ -49,7 +48,7 @@ import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import static com.appsmith.server.git.autocommit.AutoCommitEventHandlerCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static com.appsmith.server.git.autocommit.AutoCommitSolutionCEImpl.AUTO_COMMIT_MSG_FORMAT;
import static java.lang.Boolean.TRUE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
@ -59,9 +58,7 @@ import static org.mockito.Mockito.doReturn;
@SpringBootTest
@Slf4j
@DirtiesContext
public class AutoCommitEventHandlerImplTest {
@MockBean
ApplicationEventPublisher applicationEventPublisher;
public class AutoCommitSolutionImplTest {
@SpyBean
RedisUtils redisUtils;
@ -96,7 +93,7 @@ public class AutoCommitEventHandlerImplTest {
@Autowired
ProjectProperties projectProperties;
AutoCommitEventHandler autoCommitEventHandler;
AutoCommitSolution autoCommitSolution;
JsonSchemaVersions jsonSchemaVersions = new JsonSchemaVersions();
@ -106,8 +103,7 @@ public class AutoCommitEventHandlerImplTest {
@BeforeEach
public void beforeTest() {
autoCommitEventHandler = new AutoCommitEventHandlerImpl(
applicationEventPublisher,
autoCommitSolution = new AutoCommitSolutionImpl(
gitRedisUtils,
redisUtils,
dslMigrationUtils,
@ -135,7 +131,7 @@ public class AutoCommitEventHandlerImplTest {
Mono<Boolean> map = redisUtils
.startAutoCommit(defaultApplicationId, branchName)
.then(autoCommitEventHandler.autoCommitDSLMigration(autoCommitEvent));
.then(autoCommitSolution.autoCommitDSLMigration(autoCommitEvent));
StepVerifier.create(map)
.assertNext(x -> {
@ -243,7 +239,7 @@ public class AutoCommitEventHandlerImplTest {
autoCommitEvent.getPrivateKey(),
autoCommitEvent.getBranchName());
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitDSLMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -292,7 +288,7 @@ public class AutoCommitEventHandlerImplTest {
.constructArtifactExchangeJsonFromGitRepository(jsonTransformationDTO);
// the rest of the process should not trigger as no migration is required
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitDSLMigration(autoCommitEvent)
.zipWhen(result -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -353,7 +349,7 @@ public class AutoCommitEventHandlerImplTest {
autoCommitEvent.getPrivateKey(),
autoCommitEvent.getBranchName());
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(result -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -371,7 +367,7 @@ public class AutoCommitEventHandlerImplTest {
Mono<Boolean> map = redisUtils
.startAutoCommit(defaultApplicationId, branchName)
.then(autoCommitEventHandler.autoCommitServerMigration(autoCommitEvent));
.then(autoCommitSolution.autoCommitServerMigration(autoCommitEvent));
StepVerifier.create(map)
.assertNext(x -> {
@ -414,7 +410,7 @@ public class AutoCommitEventHandlerImplTest {
.saveArtifactToLocalRepoNew(baseRepoSuffix, applicationJson, autoCommitEvent.getBranchName());
// the rest of the process should not trigger as no migration is required
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(result -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -479,7 +475,7 @@ public class AutoCommitEventHandlerImplTest {
autoCommitEvent.getPrivateKey(),
autoCommitEvent.getBranchName());
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -501,7 +497,7 @@ public class AutoCommitEventHandlerImplTest {
gitFileSystemTestHelper.getApplicationJson(this.getClass().getResource("application.json"));
gitFileSystemTestHelper.setupGitRepository(autoCommitEvent, applicationJson);
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -544,7 +540,7 @@ public class AutoCommitEventHandlerImplTest {
gitFileSystemTestHelper.setupGitRepository(autoCommitEvent, applicationJson);
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitServerMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {
@ -603,7 +599,7 @@ public class AutoCommitEventHandlerImplTest {
autoCommitEvent.getBranchName());
gitFileSystemTestHelper.setupGitRepository(autoCommitEvent, applicationJson);
StepVerifier.create(autoCommitEventHandler
StepVerifier.create(autoCommitSolution
.autoCommitDSLMigration(autoCommitEvent)
.zipWhen(a -> redisUtils.getAutoCommitProgress(autoCommitEvent.getApplicationId())))
.assertNext(tuple2 -> {

View File

@ -10,7 +10,6 @@ import com.appsmith.server.domains.GitAuth;
import com.appsmith.server.domains.GitProfile;
import com.appsmith.server.dtos.AutoCommitResponseDTO;
import com.appsmith.server.events.AutoCommitEvent;
import com.appsmith.server.git.autocommit.AutoCommitEventHandler;
import com.appsmith.server.git.central.CentralGitService;
import com.appsmith.server.git.central.GitType;
import com.appsmith.server.helpers.GitPrivateRepoHelper;
@ -43,7 +42,7 @@ import static org.mockito.ArgumentMatchers.eq;
public class GitAutoCommitHelperImplTest {
@MockBean
AutoCommitEventHandler autoCommitEventHandler;
AutoCommitAsyncEventManager autoCommitAsyncEventManager;
@SpyBean
ApplicationService applicationService;
@ -205,7 +204,7 @@ public class GitAutoCommitHelperImplTest {
StepVerifier.create(gitAutoCommitHelper.autoCommitClientMigration(defaultApplicationId, branchName))
.assertNext(aBoolean -> {
assertThat(aBoolean).isTrue();
Mockito.verify(autoCommitEventHandler).publish(autoCommitEvent);
Mockito.verify(autoCommitAsyncEventManager).publishAsyncEvent(autoCommitEvent);
})
.verifyComplete();
}