From 2c13b1758443856467ca6420ea6db00641ebd676 Mon Sep 17 00:00:00 2001 From: dilhasha Date: Fri, 2 Aug 2024 09:25:45 +0530 Subject: [PATCH] Ignore type check for private fields in object mocking --- .../org/ballerinalang/testerina/natives/mock/ObjectMock.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java index b4825504ba52..c7d6040f90c6 100644 --- a/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java +++ b/misc/testerina/modules/testerina-core/src/main/java/org/ballerinalang/testerina/natives/mock/ObjectMock.java @@ -977,7 +977,9 @@ private static BError validateFunctionSignatures(MethodType func, private static BError validateField(Map.Entry mockField, Map fieldMap) { for (Map.Entry field : fieldMap.entrySet()) { if (field.getKey().equals(mockField.getKey())) { - if (TypeChecker.checkIsType(field.getValue().getFieldType(), mockField.getValue().getFieldType())) { + // Ignore type checking if the field is private + if (SymbolFlags.isFlagOn(field.getValue().getFlags(), SymbolFlags.PRIVATE) || + TypeChecker.checkIsType(field.getValue().getFieldType(), mockField.getValue().getFieldType())) { return null; } else { String detail = "incompatible field type '" + mockField.getValue().getFieldType() + "' provided " +