Skip to content

Commit

Permalink
feat: accurate match multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-myx committed Jan 5, 2024
1 parent 74e59ed commit 0df59d1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,12 @@ private static Mocker accurateMatch(Mocker requestMocker, List<MergeDTO> mergeRe
if (matchedList.size() == 1) {
return buildMatchedMocker(requestMocker, matchedList.get(0));
}
// unmatched or matched multiple (like as redis: incr、decr), next fuzzy match
// matched multiple (like as redis: incr、decr)
if (matchedList.size() > 1) {
return fuzzyMatch(requestMocker, matchedList);
}

// unmatched will fuzzy match with same method name
return null;
}

Expand All @@ -328,7 +333,7 @@ private static Mocker fuzzyMatch(Mocker requestMocker, List<MergeDTO> mergeRepla
if (Config.get().isEnableDebug()) {
String response = resultMocker != null && resultMocker.getTargetResponse() != null ?
resultMocker.getTargetResponse().getBody() : StringUtil.EMPTY;
LogManager.warn(FUZZY_MATCH_TITLE, StringUtil.format("%s%nrequest: %s%nresponse: %s",
LogManager.info(FUZZY_MATCH_TITLE, StringUtil.format("%s%nrequest: %s%nresponse: %s",
requestMocker.logBuilder().toString(), requestMocker.getTargetRequest().getBody(), response));
}
return resultMocker;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package io.arex.inst.runtime.util;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class MergeRecordReplayUtilTest {

@Test
void mergeRecord() {
}

@Test
void merge() {
}

@Test
void checkAndSplit() {
}

@Test
void recordRemain() {
}

@Test
void mergeReplay() {
}

@Test
void replayMergeMocker() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,42 @@ static void tearDown() {

@Test
void put() {
caller.put("key", "value");
assertNull(caller.put("key1", "value1"));
}

@Test
void remove() {
assertNull(caller.remove("key2"));
}

@Test
void testToString() {
assertNotNull(caller.toString());
}

@Test
void putIfAbsent() {
assertNull(caller.putIfAbsent("key3", "value3"));
}

@Test
void get() {
assertNull(caller.get("key4"));
}

@Test
void cleanUp() {
assertDoesNotThrow(() -> caller.cleanUp());
}

@Test
void keySet() {
caller.put("key6", "value6");
assertNotNull(caller.keySet());
}

@Test
void containsKey() {
assertFalse(caller.containsKey("key5"));
}
}

0 comments on commit 0df59d1

Please sign in to comment.