Skip to content

Commit

Permalink
fix: Modify the return type of the batchQueryMockers method (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
pangdayuan1 authored Sep 5, 2024
1 parent 400e708 commit 0912ac2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class MockCategoryType {

public static final Set<MockCategoryType> DEFAULTS;
public static final MockCategoryType Q_MESSAGE_CONSUMER = MockCategoryType.createEntryPoint(
public static final MockCategoryType Q_MESSAGE_CONSUMER = MockCategoryType.createSkipComparisonEntrance(
"QMessageConsumer");
public static final MockCategoryType Q_MESSAGE_PRODUCER = MockCategoryType.createDependency(
"QMessageProducer");
Expand Down Expand Up @@ -69,6 +69,10 @@ public static MockCategoryType createSkipComparison(String name) {
return new MockCategoryType(name, false, true);
}

public static MockCategoryType createSkipComparisonEntrance(String name) {
return new MockCategoryType(name, true, true);
}

public static MockCategoryType createDependency(String name) {
return new MockCategoryType(name, false, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,17 @@ public Response batchSaveMockers(@RequestBody List<AREXMocker> mockers) {

@PostMapping(value = "/batchQueryMockers")
@ResponseBody
public List<AREXQueryMocker> batchQueryMockers(@RequestBody QueryMockRequestType requestType) {
public byte[] batchQueryMockers(@RequestBody QueryMockRequestType requestType) {
if (requestType == null || StringUtils.isEmpty(requestType.getRecordId())) {
LOGGER.warn("agent batch query recordId empty");
return Collections.emptyList();
return ZstdJacksonSerializer.EMPTY_INSTANCE;
}
return handleMockerService.batchQuery(requestType.getRecordId(), requestType.getFieldNames(),
requestType.getCategoryTypes());
List<AREXQueryMocker> arexQueryMockers = handleMockerService.batchQuery(requestType.getRecordId(),
requestType.getFieldNames(), requestType.getCategoryTypes());
if (CollectionUtils.isEmpty(arexQueryMockers)) {
return ZstdJacksonSerializer.EMPTY_INSTANCE;
}
return zstdJacksonSerializer.serialize(arexQueryMockers);
}

@PostMapping(value = "/batchSaveReplayResult")
Expand Down Expand Up @@ -312,6 +316,20 @@ List<? extends Mocker> queryMockersTest(@RequestBody QueryMockRequestType reques
return null;
}

@PostMapping(value = "/batchQueryMockersTest", produces = {MediaType.APPLICATION_JSON_VALUE})
public @ResponseBody
List<AREXQueryMocker> batchQueryMockersTest(@RequestBody QueryMockRequestType requestType) {
try {
byte[] bytes = this.batchQueryMockers(requestType);
return zstdJacksonSerializer.deserialize(bytes,
new TypeReference<List<AREXQueryMocker>>() {
});
} catch (RuntimeException runtimeException) {
LOGGER.error("queryMockersTest error:{} ", runtimeException.getMessage(), runtimeException);
}
return Collections.emptyList();
}

/**
* put agent version in redis,
* when obtaining the matching relationship,
Expand Down

0 comments on commit 0912ac2

Please sign in to comment.