Skip to content

Commit

Permalink
Merge branch 'main' into fix/ignore-op-name-null-check
Browse files Browse the repository at this point in the history
  • Loading branch information
QizhengMo authored Jan 6, 2025
2 parents 947dba8 + accbb10 commit fed33b8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.arextest.schedule.progress.ProgressTracer;
import com.arextest.schedule.service.MetricService;
import com.arextest.web.model.contract.contracts.compare.CategoryDetail;
import jakarta.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -154,12 +155,9 @@ public List<ReplayCompareResult> doContentCompare(ReplayActionCaseItem caseItem,

List<ReplayCompareResult> replayCompareResults = new ArrayList<>();
for (CategoryComparisonHolder bindHolder : waitCompareMap) {
if (operationConfig.checkIgnoreMockMessageType(bindHolder.getCategoryName())) {
continue;
}
replayCompareResults.addAll(compareReplayResult(bindHolder, caseItem, operationConfig));
}
return replayCompareResults;
return replayCompareResults.stream().filter(Objects::nonNull).collect(Collectors.toList());
}

/**
Expand Down Expand Up @@ -268,7 +266,8 @@ private List<ReplayCompareResult> matchCompareReplayResults(CategoryComparisonHo
return compareResults;
}

private ReplayCompareResult compareRecordAndResult(ComparisonInterfaceConfig operationConfig,
private @Nullable ReplayCompareResult compareRecordAndResult(
ComparisonInterfaceConfig operationConfig,
ReplayActionCaseItem caseItem, String category, CompareItem target, CompareItem source) {

String operation = source != null ? source.getCompareOperation() : target.getCompareOperation();
Expand All @@ -280,17 +279,9 @@ private ReplayCompareResult compareRecordAndResult(ComparisonInterfaceConfig ope

CompareResult comparedResult = new CompareResult();
ReplayCompareResult resultNew = ReplayCompareResult.createFrom(caseItem);

// use operation config to ignore category
if (ignoreCategory(category, operation, operationConfig.getIgnoreCategoryTypes())) {
comparedResult.setCode(DiffResultCode.COMPARED_WITHOUT_DIFFERENCE);
comparedResult.setProcessedBaseMsg(record);
comparedResult.setProcessedTestMsg(replay);
mergeResult(operation, category, resultNew, comparedResult, source, target);
resultNew.setIgnore(true);
return resultNew;
return null;
}

StopWatch stopWatch = new StopWatch();
stopWatch.start(LogType.COMPARE_SDK.getValue());
comparedResult = compareProcess(category, record, replay, compareConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.arextest.schedule.model.config;


import com.arextest.model.mock.MockCategoryType;
import com.arextest.web.model.contract.contracts.compare.CategoryDetail;
import com.arextest.web.model.contract.contracts.compare.TransformDetail;
import com.arextest.web.model.contract.contracts.config.replay.ComparisonSummaryConfiguration.ReplayScriptMethod;
Expand All @@ -18,7 +17,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import lombok.Data;

Expand All @@ -27,7 +25,6 @@
*/
@Data
public class ReplayComparisonConfig {

private String operationName;
private List<String> operationTypes;
private List<CategoryDetail> ignoreCategoryTypes;
Expand Down Expand Up @@ -55,20 +52,6 @@ public class ReplayComparisonConfig {
*/
private Map<String, Object> additionalConfig;

public final boolean checkIgnoreMockMessageType(String type) {
// [b_yu] 2022-10-11 Dynamic type does not compare
if (Objects.equals(type, MockCategoryType.DYNAMIC_CLASS.getName())) {
return true;
}
if (Objects.equals(type, MockCategoryType.REDIS.getName())) {
return true;
}
if (Objects.equals(type, MockCategoryType.Q_MESSAGE_CONSUMER.getName())) {
return true;
}
return false;
}

public void fillCommonFields() {
this.setExclusionList(Collections.emptySet());
this.setInclusionList(Collections.emptySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ public class ServiceInstanceOperation {

@JsonAlias("Name")
private String name;
@JsonAlias("RequestMessage")
private DefinedMessageFormatter requestMessage;
@JsonAlias("ResponseMessage")
private DefinedMessageFormatter responseMessage;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected HttpHeaders createRequestHeaders(Map<String, String> sourceHeaders, St
contentType = contentType(format);
}
httpHeaders.setContentType(contentType);
httpHeaders.remove(HttpHeaders.CONTENT_LENGTH);
return httpHeaders;
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
<spring.boot.version>3.2.3</spring.boot.version>

<commons-lang3.version>3.3.2</commons-lang3.version>
<compare-sdk.version>0.2.18</compare-sdk.version>
<compare-sdk.version>0.2.19</compare-sdk.version>
<fastjson2.version>2.0.23</fastjson2.version>
<guava.version>29.0-jre</guava.version>
<java.version>1.8</java.version>
Expand Down

0 comments on commit fed33b8

Please sign in to comment.