Merge branch 'stable-3.11' * stable-3.11: NOOP fetches are to be considered succeded Reformat with GJF 1.24.0 Change-Id: Ie3f8f957d6c968fc7e51695ede2c65ed471d6008
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java index c69b45a..e75c4c3 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/FetchOne.java
@@ -345,7 +345,8 @@ if (replicationType == ReplicationType.ASYNC && !pool.requestRunway(this)) { if (!canceled) { repLog.info( - "[{}] Rescheduling replication from {} to avoid collision with an in-flight fetch task [{}].", + "[{}] Rescheduling replication from {} to avoid collision with an in-flight fetch task" + + " [{}].", taskIdHex, uri, pool.getInFlight(getURI()).map(FetchOne::getTaskIdHex).orElse("<unknown>")); @@ -369,7 +370,8 @@ if (fetchRefSpecs.isEmpty()) { repLog.info( - "[{}] {} replication from {} finished but no refs were replicated, {}ms delay, {} retries", + "[{}] {} replication from {} finished but no refs were replicated, {}ms delay, {}" + + " retries", taskIdHex, replicationType, uri, @@ -429,7 +431,8 @@ } } else { repLog.error( - "[{}] Giving up after {} occurrences of this error: {} during replication from [{}] {}", + "[{}] Giving up after {} occurrences of this error: {} during replication from [{}]" + + " {}", taskIdHex, lockRetryCount, e.getMessage(), @@ -489,7 +492,8 @@ } catch (InexistentRefTransportException e) { String inexistentRef = e.getInexistentRef(); repLog.info( - "[{}] Remote {} does not have ref {} in replication task, flagging as failed and removing from the replication task", + "[{}] Remote {} does not have ref {} in replication task, flagging as failed and removing" + + " from the replication task", taskIdHex, uri, inexistentRef); @@ -620,6 +624,11 @@ boolean anyRefFailed = false; RefUpdate.Result lastRefUpdateResult = RefUpdate.Result.NO_CHANGE; + // NOOP fetches are considered as successes + if (refUpdates.isEmpty()) { + succeeded = true; + } + for (RefUpdateState u : refUpdates) { ReplicationState.RefFetchResult fetchStatus = ReplicationState.RefFetchResult.SUCCEEDED; Set<ReplicationState> logStates = new HashSet<>();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/InitPlugin.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/InitPlugin.java index 5539451..ef15349 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/InitPlugin.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/InitPlugin.java
@@ -60,7 +60,8 @@ if (!bearerTokenProvider.get().isPresent()) { ui.message( - "The %s plugin is not configured to use bearer token. If you are using basic auth, remember to grant the '%s' global capability to all relevant users\n", + "The %s plugin is not configured to use bearer token. If you are using basic auth," + + " remember to grant the '%s' global capability to all relevant users\n", pluginName, GlobalCapability.ACCESS_DATABASE); return; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/PullReplicationModule.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/PullReplicationModule.java index 7972fc4..251f39f 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/PullReplicationModule.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/PullReplicationModule.java
@@ -149,7 +149,8 @@ if (e.getMessage() .contains("com/googlesource/gerrit/plugins/healthcheck/check/HealthCheck")) { flogger.atInfo().log( - "Skipping registration of pull replication health checks; healthcheck plugin API not loaded"); + "Skipping registration of pull replication health checks; healthcheck plugin API not" + + " loaded"); } else { throw e; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java index b4c6ead..495915d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationQueue.java
@@ -283,8 +283,8 @@ if (!running) { stateLog.warn( String.format( - "Replication plugin did not finish startup before event, event replication is postponed" - + " for event %s", + "Replication plugin did not finish startup before event, event replication is" + + " postponed for event %s", event), state); beforeStartupEventsQueue.add(event); @@ -470,8 +470,8 @@ fetchClient.callBatchSendObject(project, filteredRefsBatch, eventCreatedOn, uri)); resultSuccessful = HttpResultUtils.isSuccessful(result); repLog.info( - "Pull replication REST API batch apply object to {} COMPLETED for {}:[{}], HTTP Result:" - + " {} - time:{} ms", + "Pull replication REST API batch apply object to {} COMPLETED for {}:[{}], HTTP " + + " Result: {} - time:{} ms", apiUrl, project, batchApplyObjectStr, @@ -479,7 +479,8 @@ apiTimer.stop() / 1000000.0); } else { repLog.info( - "REST API batch apply object not enabled for source {}, using REST API apply object to {} for {}:[{}]", + "REST API batch apply object not enabled for source {}, using REST API apply object" + + " to {} for {}:[{}]", remoteName, apiUrl, project, @@ -569,8 +570,11 @@ private List<RevisionData> fetchWholeMetaHistory( NameKey project, String refName, RevisionData revision) - throws RepositoryNotFoundException, MissingObjectException, IncorrectObjectTypeException, - CorruptObjectException, IOException { + throws RepositoryNotFoundException, + MissingObjectException, + IncorrectObjectTypeException, + CorruptObjectException, + IOException { RevisionReader revisionReader = revReaderProvider.get(); Optional<RevisionData> revisionDataWithParents = revisionReader.read(project, refName, Integer.MAX_VALUE);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationSources.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationSources.java index 25f42cd..d825609 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationSources.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/ReplicationSources.java
@@ -27,7 +27,9 @@ */ List<Source> getAll(); - /** @return true if there are no destinations, false otherwise. */ + /** + * @return true if there are no destinations, false otherwise. + */ boolean isEmpty(); /**
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/RevisionReader.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/RevisionReader.java index 0d17a75..9458083 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/RevisionReader.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/RevisionReader.java
@@ -75,8 +75,11 @@ public Optional<RevisionData> read( Project.NameKey project, String refName, int maxParentObjectIds) - throws RepositoryNotFoundException, MissingObjectException, IncorrectObjectTypeException, - CorruptObjectException, IOException { + throws RepositoryNotFoundException, + MissingObjectException, + IncorrectObjectTypeException, + CorruptObjectException, + IOException { return read(project, null, refName, maxParentObjectIds); } @@ -85,8 +88,11 @@ @Nullable ObjectId refObjectId, String refName, int maxParentObjectIds) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, - RepositoryNotFoundException, IOException { + throws MissingObjectException, + IncorrectObjectTypeException, + CorruptObjectException, + RepositoryNotFoundException, + IOException { try (Repository git = gitRepositoryManager.openRepository(project)) { Long totalRefSize = 0l; @@ -190,7 +196,9 @@ } private List<DiffEntry> readDiffs(Repository git, RevCommit commit, RevTree tree, TreeWalk walk) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, + throws MissingObjectException, + IncorrectObjectTypeException, + CorruptObjectException, IOException { walk.setFilter(TreeFilter.ANY_DIFF); walk.reset(getParentTree(git, commit), tree); @@ -199,7 +207,9 @@ private List<RevisionObjectData> readBlobs( Project.NameKey projectName, String refName, Repository git, Long totalRefSize, TreeWalk walk) - throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, + throws MissingObjectException, + IncorrectObjectTypeException, + CorruptObjectException, IOException { List<RevisionObjectData> blobs = Lists.newLinkedList(); while (walk.next()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java index 4d30c97..320e9ec 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/Source.java
@@ -391,7 +391,8 @@ } } catch (AuthException e) { repLog.warn( - "NOT scheduling replication {}:{} because lack of permissions to access project/ref", + "NOT scheduling replication {}:{} because lack of permissions to access" + + " project/ref", project, refSpec); return false; @@ -635,7 +636,8 @@ stateLog.warn( String.format( - "[%s] Merging all refs to fetch from [%s] to the already retrying task [%s] for keeping its position into the replication queue", + "[%s] Merging all refs to fetch from [%s] to the already retrying task [%s] for" + + " keeping its position into the replication queue", fetchOp.getTaskIdHex(), fetchOp.getURI(), pendingFetchOp.getTaskIdHex()), fetchOp.getStatesAsArray());
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfigParser.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfigParser.java index f7deaf4..d76dbc0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfigParser.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfigParser.java
@@ -77,10 +77,11 @@ if (sourceConfig.fetchEvery() > SourceConfiguration.DEFAULT_PERIODIC_FETCH_DISABLED && !sourceConfig.getApis().isEmpty()) { logger.atSevere().log( - "Receiving updates through periodic fetch (every %ds) and from Gerrit API(s) (%s) as a result of " - + "received events (in %s node) may result in racy writes to the repo (in extreme cases to its " - + "corruption). Periodic fetch is meant ONLY for remote that that doesn't offer events or " - + "webhooks that could be used otherwise for new data detection.", + "Receiving updates through periodic fetch (every %ds) and from Gerrit API(s) (%s) as a" + + " result of received events (in %s node) may result in racy writes to the repo" + + " (in extreme cases to its corruption). Periodic fetch is meant ONLY for remote" + + " that that doesn't offer events or webhooks that could be used otherwise for new" + + " data detection.", sourceConfig.fetchEvery(), sourceConfig.getApis(), c.getName()); throw new ConfigInvalidException( String.format(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfiguration.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfiguration.java index faba805..a53ef54 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfiguration.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/SourceConfiguration.java
@@ -72,8 +72,9 @@ int connectionTimeoutInSec = connectionTimeout / 1000; if (connectionTimeoutInSec < getRemoteConfig().getTimeout()) { logger.atWarning().log( - "The connection timeout is currently set to %s sec, which is less than the timeout value of %s sec. " - + "To avoid potential issues, consider increasing the connection timeout to exceed the timeout value.", + "The connection timeout is currently set to %s sec, which is less than the timeout value" + + " of %s sec. To avoid potential issues, consider increasing the connection timeout" + + " to exceed the timeout value.", connectionTimeoutInSec, getRemoteConfig().getTimeout()); } idleTimeout = cfg.getInt("remote", name, "idleTimeout", DEFAULT_MAX_CONNECTION_INACTIVITY_MS); @@ -126,10 +127,10 @@ enableBatchedRefs = cfg.getBoolean("remote", name, "enableBatchedRefs", true); if (!enableBatchedRefs) { logger.atWarning().log( - "You haven't enabled batched refs in the %s node, as such you are not " - + "leveraging the performance improvements introduced by the batch-apply-object API. Consider " - + "upgrading the plugin to the latest version and consult the plugin's documentation for more " - + "details on the `enableBatchedRefs` configuration.", + "You haven't enabled batched refs in the %s node, as such you are not leveraging the" + + " performance improvements introduced by the batch-apply-object API. Consider" + + " upgrading the plugin to the latest version and consult the plugin's documentation" + + " for more details on the `enableBatchedRefs` configuration.", name); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectCommand.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectCommand.java index cef0065..16fdbb8 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectCommand.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectCommand.java
@@ -91,8 +91,11 @@ RevisionData revisionsData, String sourceLabel, long eventCreatedOn) - throws IOException, RefUpdateException, MissingParentObjectException, - ResourceNotFoundException, MissingLatestPatchSetException { + throws IOException, + RefUpdateException, + MissingParentObjectException, + ResourceNotFoundException, + MissingLatestPatchSetException { applyObjects(name, refName, new RevisionData[] {revisionsData}, sourceLabel, eventCreatedOn); } @@ -102,8 +105,11 @@ RevisionData[] revisionsData, String sourceLabel, long eventCreatedOn) - throws IOException, RefUpdateException, MissingParentObjectException, - ResourceNotFoundException, MissingLatestPatchSetException { + throws IOException, + RefUpdateException, + MissingParentObjectException, + ResourceNotFoundException, + MissingLatestPatchSetException { repLog.info( "Apply object from {} for {}:{} - {}",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java index 1d5ecec..c55d339 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/FetchAction.java
@@ -172,8 +172,11 @@ } private Response<?> applySync(Project.NameKey project, BatchInput input) - throws InterruptedException, ExecutionException, RemoteConfigurationMissingException, - TimeoutException, TransportException { + throws InterruptedException, + ExecutionException, + RemoteConfigurationMissingException, + TimeoutException, + TransportException { command.fetchSync(project, input.label, input.getRefSpecs()); return Response.created(input); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/HttpServletOps.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/HttpServletOps.java index b424555..79c0dee 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/HttpServletOps.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/HttpServletOps.java
@@ -38,7 +38,8 @@ setResponse( rsp, HttpServletResponse.SC_BAD_REQUEST, - "No advertised 'Accept' headers can be honoured. 'text/plain' should be provided in the request 'Accept' header."); + "No advertised 'Accept' headers can be honoured. 'text/plain' should be provided in the" + + " request 'Accept' header."); return false; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java index f9f2ffe..3214787 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/api/ProjectInitializationAction.java
@@ -157,8 +157,13 @@ private boolean initProjectWithConfiguration( HttpServletRequest httpServletRequest, String gitRepositoryName) - throws AuthException, PermissionBackendException, IOException, BadRequestException, - MissingParentObjectException, RefUpdateException, ResourceNotFoundException { + throws AuthException, + PermissionBackendException, + IOException, + BadRequestException, + MissingParentObjectException, + RefUpdateException, + ResourceNotFoundException { RevisionsInput input = PayloadSerDes.parseRevisionsInput(httpServletRequest); validateInput(input); @@ -177,7 +182,8 @@ input.getEventCreatedOn()); } catch (MissingLatestPatchSetException e) { repLog.error( - "Init project API FAILED from {} for {} - configuration data cannot contain change meta refs: {}:{}", + "Init project API FAILED from {} for {} - configuration data cannot contain change meta" + + " refs: {}:{}", input.getLabel(), projectName, input.getRefName(),
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/StreamEventListener.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/StreamEventListener.java index 6ca79e6..f863148 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/StreamEventListener.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/event/StreamEventListener.java
@@ -111,7 +111,10 @@ } public void fetchRefsForEvent(Event event) - throws AuthException, PermissionBackendException, IOException, UnprocessableEntityException, + throws AuthException, + PermissionBackendException, + IOException, + UnprocessableEntityException, ResourceNotFoundException { if (instanceId.equals(event.instanceId) || !shouldReplicateProject(event)) { return; @@ -130,7 +133,8 @@ if (isApplyObjectsCacheHit(refUpdatedEvent)) { logger.atFine().log( - "Skipping refupdate '%s' '%s'=>'%s' (eventCreatedOn=%d) for project '%s' because has been already replicated via apply-object", + "Skipping refupdate '%s' '%s'=>'%s' (eventCreatedOn=%d) for project '%s' because has" + + " been already replicated via apply-object", refUpdatedEvent.getRefName(), refUpdatedEvent.refUpdate.get().oldRev, refUpdatedEvent.refUpdate.get().newRev,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ApplyObject.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ApplyObject.java index 70b4795..2863012 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ApplyObject.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ApplyObject.java
@@ -47,7 +47,9 @@ } public RefUpdateState apply(Project.NameKey name, RefSpec refSpec, RevisionData[] revisionsData) - throws MissingParentObjectException, IOException, ResourceNotFoundException, + throws MissingParentObjectException, + IOException, + ResourceNotFoundException, MissingLatestPatchSetException { try (Repository git = gitManager.openRepository(name)) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ChangeMetaCommitValidator.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ChangeMetaCommitValidator.java index 4e080af..55ae734 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ChangeMetaCommitValidator.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/ChangeMetaCommitValidator.java
@@ -56,7 +56,8 @@ RevCommit patchSetCommit = repo.parseCommit(patchSetObjectId.get()); logger.atFine().log( - "Change on repository %s ref %s has latest patch-set %d and is successfully resolved to %s with commit %s", + "Change on repository %s ref %s has latest patch-set %d and is successfully resolved to %s" + + " with commit %s", repo, refName, latestPatchSet.getAsInt(), patchSetObjectId.get().getName(), patchSetCommit); return true;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/FetchFactory.java b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/FetchFactory.java index 55f8f01..e475e00 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/FetchFactory.java +++ b/src/main/java/com/googlesource/gerrit/plugins/replication/pull/fetch/FetchFactory.java
@@ -19,6 +19,7 @@ public interface FetchFactory { Fetch create(String taskIdHex, URIish uri, Repository git); + // Return implementation without any decorators @FetchClientImplementation Fetch createPlainImpl(String taskIdHex, URIish uri, Repository git);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/PermanentFailureExceptionTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/PermanentFailureExceptionTest.java index fcb0702..f9c27dc 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/PermanentFailureExceptionTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/PermanentFailureExceptionTest.java
@@ -48,7 +48,8 @@ assertThat( PermanentTransportException.wrapIfPermanentTransportException( new TransportException( - "Cannot fetch from repo, error message: fatal: couldn't find remote ref refs/heads/foobranch"))) + "Cannot fetch from repo, error message: fatal: couldn't find remote ref" + + " refs/heads/foobranch"))) .isInstanceOf(InexistentRefTransportException.class); } }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionIT.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionIT.java index e771e7a..2316fa9 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionIT.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionIT.java
@@ -38,7 +38,8 @@ String payloadWithAsyncFieldTemplate = "{\"label\":\"" + TEST_REPLICATION_REMOTE - + "\",\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}, \"async\":true}"; + + "\",\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}," + + " \"async\":true}"; Optional<RevisionData> revisionDataOption = createRevisionData(REFS_HEADS_MASTER); assertThat(revisionDataOption.isPresent()).isTrue(); @@ -157,7 +158,8 @@ @GerritConfig(name = "gerrit.instanceId", value = "testInstanceId") public void shouldReturnBadRequestCodeWhenMandatoryFieldLabelIsMissing() throws Exception { String payloadWithoutLabelFieldTemplate = - "{\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}, \"async\":true}"; + "{\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}," + + " \"async\":true}"; String refName = createRef(); Optional<RevisionData> revisionDataOption = createRevisionData(refName); @@ -180,7 +182,8 @@ String wrongPayloadTemplate = "{\"label\":\"" + TEST_REPLICATION_REMOTE - + "\",\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}, \"async\":true,}"; + + "\",\"ref_name\":\"%s\",\"revision_data\":{\"commit_object\":{\"sha1\":\"%s\",\"type\":1,\"content\":\"%s\"},\"tree_object\":{\"type\":2,\"content\":\"%s\"},\"blobs\":[]}," + + " \"async\":true,}"; String refName = createRef(); Optional<RevisionData> revisionDataOption = createRevisionData(refName);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionTest.java index 1d3acc6..dfcf6b2 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/ApplyObjectActionTest.java
@@ -66,7 +66,8 @@ + sampleTreeObjectId + "\n" + "parent 20eb48d28be86dc88fb4bef747f08de0fbefe12d\n" - + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610471611 +0100\n" + + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610471611" + + " +0100\n" + "committer Gerrit Code Review <root@maczech-XPS-15> 1610471611 +0100\n" + "\n" + "Update patch set 1\n" @@ -80,7 +81,8 @@ + "Label: SUBM=+1\n" + "Submission-id: 1904-1610471611558-783c0a2f\n" + "Submitted-with: OK\n" - + "Submitted-with: OK: Code-Review: Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac>"; + + "Submitted-with: OK: Code-Review: Gerrit User 1000000" + + " <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac>"; @Mock ApplyObjectCommand applyObjectCommand; @Mock ProjectResource projectResource;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/BatchApplyObjectActionTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/BatchApplyObjectActionTest.java index d8dabf1..65ee571 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/BatchApplyObjectActionTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/BatchApplyObjectActionTest.java
@@ -56,7 +56,8 @@ + SAMPLE_TREE_OBJECT_ID + "\n" + "parent 20eb48d28be86dc88fb4bef747f08de0fbefe12d\n" - + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610471611 +0100\n" + + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610471611" + + " +0100\n" + "committer Gerrit Code Review <root@maczech-XPS-15> 1610471611 +0100\n" + "\n" + "Update patch set 1\n" @@ -70,7 +71,8 @@ + "Label: SUBM=+1\n" + "Submission-id: 1904-1610471611558-783c0a2f\n" + "Submitted-with: OK\n" - + "Submitted-with: OK: Code-Review: Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac>"; + + "Submitted-with: OK: Code-Review: Gerrit User 1000000" + + " <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac>"; @Mock private ApplyObjectAction applyObjectAction; @Mock private ProjectResource projectResource;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/PullReplicationFilterTest.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/PullReplicationFilterTest.java index bc9e870..7cffc60 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/PullReplicationFilterTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/api/PullReplicationFilterTest.java
@@ -143,11 +143,9 @@ @Test public void shouldFilterBatchFetchAction() throws Exception { byte[] payloadBatchFetch = - ("{" - + "\"label\":\"Replication\", " - + "\"ref_inputs\": [ {\"ref_name\":\"refs/heads/master\", \"is_delete\":false}, {\"ref_name\":\"refs/heads/test\", \"is_delete\":false} ], " - + "\"async\":false" - + "}") + ("{\"label\":\"Replication\", \"ref_inputs\": [ {\"ref_name\":\"refs/heads/master\"," + + " \"is_delete\":false}, {\"ref_name\":\"refs/heads/test\", \"is_delete\":false} ], " + + "\"async\":false}") .getBytes(StandardCharsets.UTF_8); defineBehaviours(payloadBatchFetch, BATCH_FETCH_URI);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java index 595fb8f..7f0df41 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java +++ b/src/test/java/com/googlesource/gerrit/plugins/replication/pull/client/FetchRestApiClientBase.java
@@ -119,7 +119,8 @@ + treeObjectId + "\n" + "parent 983ff1a3cf74725a53a5dec8d0c06122128f5a8d\n" - + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610578648 +0100\n" + + "author Gerrit User 1000000 <1000000@69ec38f0-350e-4d9c-96d4-bc956f2faaac> 1610578648" + + " +0100\n" + "committer Gerrit Code Review <root@maczech-XPS-15> 1610578648 +0100\n" + "\n" + "Update patch set 1\n"