Skip to content

Commit

Permalink
Address the review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Thevakumar-Luheerathan committed Feb 2, 2024
1 parent 025f800 commit ef0fc46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ public void generateMockFunctions(BLangPackage pkgNode) {
Map<String, String> mockFunctionMap = pkgNode.getTestablePkg().getMockFunctionNamesMap();

// Get the mock function type map from the pkgNode
Map<String, String> mockFunctionTypeMap = pkgNode.getTestablePkg().getMockFunctionTypeMap();
Map<String, Boolean> isLegacyMockingMap = pkgNode.getTestablePkg().getIsLegacyMockingMap();

// Get the set of functions to generate
Set<String> mockFunctionSet = mockFunctionMap.keySet();
for (String function : mockFunctionSet) {
if ("LATEST".equals(mockFunctionTypeMap.get(function))) {
if (!isLegacyMockingMap.get(function)) {
pkgNode.getTestablePkg().functions.add(generateMockFunction(function));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class BLangTestablePackage extends BLangPackage {
//Map to maintain all the mock functions
private Map<String, String> mockFunctionNamesMap = new HashMap<>();

private final Map<String, String> mockFunctionTypeMap = new HashMap<>();
private final Map<String, Boolean> isLegacyMockingMap = new HashMap<>();
public Map<String, String> getMockFunctionNamesMap() {
return mockFunctionNamesMap;
}
Expand All @@ -49,11 +49,11 @@ public <T, R> R apply(BLangNodeTransformer<T, R> modifier, T props) {
return modifier.transform(this, props);
}

public Map<String, String> getMockFunctionTypeMap() {
return mockFunctionTypeMap;
public Map<String, Boolean> getIsLegacyMockingMap() {
return isLegacyMockingMap;
}

public void addMockFunctionType(String id, String type) {
this.mockFunctionTypeMap.put(id, type);
public void addIsLegacyMockingMap(String id, Boolean isLegacy) {
this.isLegacyMockingMap.put(id, isLegacy);
}

Check warning on line 58 in compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangTestablePackage.java

View check run for this annotation

Codecov / codecov/patch

compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/tree/BLangTestablePackage.java#L57-L58

Added lines #L57 - L58 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ public void process(SimpleVariableNode simpleVariableNode, List<AnnotationAttach
bLangTestablePackage.addMockFunction(
functionToMockID + MOCK_FN_DELIMITER + annotationValues[1],
mockFnObjectName);
bLangTestablePackage.addMockFunctionType(
functionToMockID + MOCK_FN_DELIMITER + annotationValues[1], "LATEST");
bLangTestablePackage.addIsLegacyMockingMap(
functionToMockID + MOCK_FN_DELIMITER + annotationValues[1], false);

if (functionToMockID != null) {
// Adding `<className> # <functionToMock> --> <MockFnObjectName>` to registry
Expand Down Expand Up @@ -259,8 +259,8 @@ public void process(FunctionNode functionNode, List<AnnotationAttachmentNode> an
(BLangTestablePackage) ((BLangFunction) functionNode).parent; // parent -> BLangPackage
bLangTestablePackage.addMockFunction(functionToMockID + MOCK_LEGACY_DELIMITER + vals[1],
functionName);
bLangTestablePackage.addMockFunctionType(functionToMockID + MOCK_LEGACY_DELIMITER + vals[1],
"LEGACY");
bLangTestablePackage.addIsLegacyMockingMap(functionToMockID + MOCK_LEGACY_DELIMITER + vals[1],
true);

// Adding `<className> # <functionToMock> --> <MockFnObjectName>` to registry
String className = getQualifiedClassName(bLangTestablePackage,
Expand Down

0 comments on commit ef0fc46

Please sign in to comment.