Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: CategoryIgnore config incremental update #351

Merged
merged 5 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arex-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.16</version>
<version>0.6.0.17</version>
</parent>
<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Response viewRecord(@RequestBody ViewRecordRequestType requestType) {
status.setResponseDesc("success");
status.setResponseCode(ResponseCode.SUCCESS.getCodeValue());
res.setResponseStatusType(status);

res.setDesensitized(storageRes.getBody().isDesensitized());
List<AREXMocker> mockers = storageRes.getBody().getRecordResult();
res.setRecordResult(CaseDetailMockerProcessor.convertMocker(mockers));
}
Expand Down
2 changes: 1 addition & 1 deletion arex-web-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.16</version>
<version>0.6.0.17</version>
</parent>
</project>
2 changes: 1 addition & 1 deletion arex-web-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.16</version>
<version>0.6.0.17</version>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,22 @@
import com.arextest.web.model.contract.contracts.compare.CategoryDetail;
import com.arextest.web.model.contract.contracts.config.replay.ComparisonIgnoreCategoryConfiguration;
import com.arextest.web.model.dto.filesystem.FSInterfaceDto;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
* @author wildeslam.
* @create 2023/8/18 14:57
*/
@Slf4j
@Component
public class ComparisonIgnoreCategoryConfigurableHandler
extends AbstractComparisonConfigurableHandler<ComparisonIgnoreCategoryConfiguration> {

private static final Set<String> CATEGORIES =
MockCategoryType.DEFAULTS.stream().map(MockCategoryType::getName)
.collect(java.util.stream.Collectors.toSet());
@Resource
FSInterfaceRepository fsInterfaceRepository;
@Resource
Expand Down Expand Up @@ -60,17 +58,14 @@ public List<ComparisonIgnoreCategoryConfiguration> queryByInterfaceId(String int
}

private void checkBeforeModify(ComparisonIgnoreCategoryConfiguration configuration) {
if (configuration.getIgnoreCategories() == null) {
CategoryDetail category = configuration.getIgnoreCategoryDetail();
if (category == null) {
return;
}
for (CategoryDetail category : configuration.getIgnoreCategories()) {
if (!CATEGORIES.contains(category.getOperationType())) {
throw new IllegalArgumentException("Invalid category: " + category);
}
if (MockCategoryType.create(category.getOperationType()).isEntryPoint()) {
throw new IllegalArgumentException("Cannot ignore entrypoint category: " + category);
}
if (MockCategoryType.create(category.getOperationType()).isEntryPoint()) {
throw new IllegalArgumentException("Cannot ignore entrypoint category: " + category);
}

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ protected Map<String, ReplayCompareConfig.ReplayComparisonItem> buildMultiConfig
ignoreCategoryConfigurableHandler.useResultAsList(appId),
(configurations, summaryConfiguration) -> {
List<CategoryDetail> ignoreCategoryTypes = configurations.stream()
.map(ComparisonIgnoreCategoryConfiguration::getIgnoreCategories)
.flatMap(Collection::stream)
.map(ComparisonIgnoreCategoryConfiguration::getIgnoreCategoryDetail)
.collect(Collectors.toList());
summaryConfiguration.setIgnoreCategoryTypes(ignoreCategoryTypes);
}, operationInfoMap, appContractDtoMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean update(ComparisonIgnoreCategoryConfiguration configuration) {
Query query = Query.query(Criteria.where(DASH_ID).is(configuration.getId()));
Update update = MongoHelper.getConfigUpdate();
MongoHelper.appendSpecifiedProperties(update, configuration,
ConfigComparisonIgnoreCategoryCollection.Fields.ignoreCategory,
ConfigComparisonIgnoreCategoryCollection.Fields.ignoreCategoryDetail,
AbstractComparisonDetails.Fields.expirationType,
AbstractComparisonDetails.Fields.expirationDate);
UpdateResult updateResult =
Expand Down
2 changes: 1 addition & 1 deletion arex-web-model-contract/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.16</version>
<version>0.6.0.17</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.arextest.web.model.contract.contracts.compare;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* @author wildeslam.
* @create 2024/1/5 15:45
*/
@Data
public class CategoryDetail {
@EqualsAndHashCode.Include
private String operationType;

@EqualsAndHashCode.Include
private String operationName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,5 @@
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class ComparisonIgnoreCategoryConfiguration extends AbstractComparisonDetailsConfiguration {

private List<CategoryDetail> ignoreCategories;

@Override
public void validParameters() throws Exception {
super.validParameters();
if (CollectionUtils.isEmpty(ignoreCategories)) {
throw new Exception("ignoreCategory cannot be empty");
}
}
private CategoryDetail ignoreCategoryDetail;
}
2 changes: 1 addition & 1 deletion arex-web-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
<parent>
<artifactId>arex-web</artifactId>
<groupId>com.arextest</groupId>
<version>0.6.0.16</version>
<version>0.6.0.17</version>
</parent>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,5 @@
@ToString(callSuper = true)
@Document(collection = "ConfigComparisonIgnoreCategory")
public class ConfigComparisonIgnoreCategoryCollection extends AbstractComparisonDetails {

@Deprecated
private List<String> ignoreCategory;

private List<CategoryDetailDao> ignoreCategories;
private CategoryDetailDao ignoreCategoryDetail;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,4 @@ public interface ConfigComparisonIgnoreCategoryMapper {
@Mapping(target = "dataChangeUpdateTime", expression = "java(System.currentTimeMillis())"),
})
ConfigComparisonIgnoreCategoryCollection daoFromDto(ComparisonIgnoreCategoryConfiguration dto);

@BeforeMapping
default void compatible(ConfigComparisonIgnoreCategoryCollection dao) {
if (CollectionUtils.isNotEmpty(dao.getIgnoreCategory())) {
if (dao.getIgnoreCategories() == null) {
dao.setIgnoreCategories(new ArrayList<>());
}
dao.getIgnoreCategories().forEach(categoryDetail -> {
if (dao.getIgnoreCategory().contains(categoryDetail.getOperationType())) {
categoryDetail.setOperationName(null);
} else {
CategoryDetailDao categoryDetailDao = new CategoryDetailDao();
categoryDetailDao.setOperationType(categoryDetail.getOperationType());
dao.getIgnoreCategories().add(categoryDetailDao);
}
});
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -386,5 +386,5 @@

<url>https://github.com/arextest/arex-report</url>

<version>0.6.0.16</version>
<version>0.6.0.17</version>
</project>