Skip to content

Commit

Permalink
adding cases #1
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAmg committed Dec 26, 2023
1 parent b985452 commit b84977a
Show file tree
Hide file tree
Showing 14 changed files with 1,421 additions and 75 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<dependency>
<artifactId>unlogged-sdk</artifactId>
<groupId>video.bug</groupId>
<version>0.1.36</version>
<version>0.1.37</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,4 @@ public List<CustomerProfile> getInternationalCustomers() {
"4678251601", "Hella, Iceland", referralCodes);
return customerProfiles;
}

public void throwSomeException() {
String a = "a".split(" ")[12];
}
}
4 changes: 3 additions & 1 deletion src/main/java/org/unlogged/demo/service/CustomerService.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ public CustomerScoreCard isCustomerEligibleForPremium(long customerID) {

public List<CustomerProfile> filterEligbleCustomers(List<CustomerProfile> customers, boolean asiaFlow) {
List<CustomerProfile> eligibleCustomers = new ArrayList<>();
eligibleCustomers = customerProfileRepository.getAsianCustomers();
if (asiaFlow) {
customers = customerProfileRepository.getAsianCustomers();
}
if (asiaFlow) {
for (CustomerProfile customer : customers) {
int bonus = 0;
Expand Down
28 changes: 28 additions & 0 deletions src/test/resources/unlogged/java.util.TreeMap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"classname" : "java.util.TreeMap",
"storedCandidateMap" : { },
"declaredMockMap" : {
"java.util.TreeMap#get#(Ljava/lang/Object;)Ljava/lang/Object;" : [ {
"id" : "ccb05a27-9329-4d92-aef5-829acb250665",
"name" : "cpr1 - get mock profile",
"fieldTypeName" : "java.util.TreeMap",
"sourceClassName" : "org.unlogged.demo.repository.CustomerProfileRepository",
"fieldName" : "profileTreeMap",
"methodName" : "get",
"whenParameter" : [ {
"name" : "key",
"type" : "ANY_OF_TYPE",
"value" : "long"
} ],
"thenParameter" : [ {
"returnParameter" : {
"declaredMocks" : [ ],
"value" : "{\"customerid\": 0, \"customername\": \"string\", \"dateofbirth\": \"string\", \"email\": \"string\", \"contactnumber\": \"string\", \"address\": \"string\", \"referralcodes\": [\"string\"]}",
"returnValueType" : "REAL",
"className" : "org.unlogged.demo.models.CustomerProfile"
},
"methodExitType" : "NORMAL"
} ]
} ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"classname" : "org.springframework.data.repository.CrudRepository",
"storedCandidateMap" : { },
"declaredMockMap" : {
"org.springframework.data.repository.CrudRepository#save#(Ljava/lang/Object;)Ljava/lang/Object;" : [ {
"id" : "a26748e0-50b1-4b4e-81c4-4efe75ebf3e7",
"name" : "cr - save customer profile",
"fieldTypeName" : "org.springframework.data.repository.CrudRepository",
"sourceClassName" : "org.unlogged.demo.service.CustomerService",
"fieldName" : "repo",
"methodName" : "save",
"whenParameter" : [ {
"name" : "entity",
"type" : "ANY_OF_TYPE",
"value" : "org.unlogged.demo.models.CustomerProfile"
} ],
"thenParameter" : [ {
"returnParameter" : {
"declaredMocks" : [ ],
"value" : "{\"customerid\": 0, \"customername\": \"string\", \"dateofbirth\": \"string\", \"email\": \"string\", \"contactnumber\": \"string\", \"address\": \"string\", \"referralcodes\": [\"string\"]}",
"returnValueType" : "REAL",
"className" : "org.unlogged.demo.models.CustomerProfile"
},
"methodExitType" : "NORMAL"
} ]
} ]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
{
"classname" : "org.unlogged.demo.controller.CustomerController",
"storedCandidateMap" : {
"org.unlogged.demo.controller.CustomerController#saveCustomerProfile#(Lorg/unlogged/demo/models/CustomerProfileRequest;)Lorg/unlogged/demo/models/CustomerProfile;" : [ {
"lineNumbers" : [ 29 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"id" : "4a05383c-97f5-4cc4-bb79-c45f086020ea",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "474a3da8-36e4-4af1-90f4-abb4f5e86792",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "c3ea745d-aa05-44de-9f55-ddf7eb4a697e",
"name" : "save customer 0",
"description" : "should pass",
"methodArguments" : [ "{\"customerName\":\"string\",\"dateOfBirth\":\"string\",\"email\":\"string\",\"primaryNumber\":\"string\",\"address\":\"string\",\"codes\":[\"string\"]}" ],
"returnValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"returnValueClassname" : "org.unlogged.demo.models.CustomerProfile",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703576622614,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : 542951060,
"probSerializedValue" : "eyJjdXN0b21lcmlkIjowLCJjdXN0b21lcm5hbWUiOiJzdHJpbmciLCJkYXRlb2ZiaXJ0aCI6InN0cmluZyIsImVtYWlsIjoic3RyaW5nIiwiY29udGFjdG51bWJlciI6InN0cmluZyIsImFkZHJlc3MiOiJzdHJpbmciLCJyZWZlcnJhbGNvZGVzIjpbInN0cmluZyJdfQ==",
"mockIds" : [ "cf87ae24-a734-4b87-9302-71b4e40e3bfa" ],
"exception" : false,
"method" : {
"name" : "saveCustomerProfile",
"signature" : "(Lorg/unlogged/demo/models/CustomerProfileRequest;)Lorg/unlogged/demo/models/CustomerProfile;",
"className" : "org.unlogged.demo.controller.CustomerController",
"methodHash" : -916697858
}
} ],
"org.unlogged.demo.controller.CustomerController#generateNeReferralCode#(J)Lorg/unlogged/demo/models/CustomerProfile;" : [ {
"lineNumbers" : [ 39 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"code-1\",\"code-2\"]}",
"id" : "060da5e3-9a81-4fce-a1f2-3730804d415e",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "310e7b9f-9ded-4826-93cb-650879e1231d",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "c6a9813a-f2e8-4c4f-8353-6521b6923acf",
"name" : "add referral code for customer",
"description" : "should pass",
"methodArguments" : [ "0" ],
"returnValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"code-1\",\"code-2\"]}",
"returnValueClassname" : "org.unlogged.demo.models.CustomerProfile",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703576748845,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : 453595400,
"probSerializedValue" : "eyJjdXN0b21lcmlkIjowLCJjdXN0b21lcm5hbWUiOiJzdHJpbmciLCJkYXRlb2ZiaXJ0aCI6InN0cmluZyIsImVtYWlsIjoic3RyaW5nIiwiY29udGFjdG51bWJlciI6InN0cmluZyIsImFkZHJlc3MiOiJzdHJpbmciLCJyZWZlcnJhbGNvZGVzIjpbImNvZGUtMSIsImNvZGUtMiJdfQ==",
"mockIds" : [ "077b0593-8e95-4132-a552-ad171ba1633c" ],
"exception" : false,
"method" : {
"name" : "generateNeReferralCode",
"signature" : "(J)Lorg/unlogged/demo/models/CustomerProfile;",
"className" : "org.unlogged.demo.controller.CustomerController",
"methodHash" : -732548036
}
} ],
"org.unlogged.demo.controller.CustomerController#isCustomerEligibleForLoyaltyProgram#(J)Lorg/unlogged/demo/models/CustomerScoreCard;" : [ {
"lineNumbers" : [ 43 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"customerProfile\":{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]},\"score\":50,\"isEligible\":true}",
"id" : "536a3182-478d-4cd9-9961-e6d02fb112ab",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "8f8e78cb-d278-4ebb-8a21-b9e8ee169018",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "64249160-5a61-49e2-98c4-148b09d8cbc5",
"name" : "customer 0 should be eligible",
"description" : "should pass",
"methodArguments" : [ "0" ],
"returnValue" : "{\"customerProfile\":{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]},\"score\":50,\"isEligible\":true}",
"returnValueClassname" : "org.unlogged.demo.models.CustomerScoreCard",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703576805039,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : 1276962101,
"probSerializedValue" : "eyJjdXN0b21lclByb2ZpbGUiOnsiY3VzdG9tZXJpZCI6MCwiY3VzdG9tZXJuYW1lIjoic3RyaW5nIiwiZGF0ZW9mYmlydGgiOiJzdHJpbmciLCJlbWFpbCI6InN0cmluZyIsImNvbnRhY3RudW1iZXIiOiJzdHJpbmciLCJhZGRyZXNzIjoic3RyaW5nIiwicmVmZXJyYWxjb2RlcyI6WyJzdHJpbmciXX0sInNjb3JlIjo1MCwiaXNFbGlnaWJsZSI6dHJ1ZX0=",
"mockIds" : [ "38710293-7956-4ce0-8144-615e24946868" ],
"exception" : false,
"method" : {
"name" : "isCustomerEligibleForLoyaltyProgram",
"signature" : "(J)Lorg/unlogged/demo/models/CustomerScoreCard;",
"className" : "org.unlogged.demo.controller.CustomerController",
"methodHash" : -2119348806
}
} ],
"org.unlogged.demo.controller.CustomerController#getCustomerProfile#(J)Lorg/unlogged/demo/models/CustomerProfile;" : [ {
"lineNumbers" : [ 22, 23 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"id" : "aa736739-d85d-457e-839a-be746e5b865c",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "7541e425-b46e-4a3f-a70a-3b20f4188110",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "6a657506-707a-4876-bfe3-b68f0eed72f6",
"name" : "get customer - 0",
"description" : "get customer 0 - should pass",
"methodArguments" : [ "0" ],
"returnValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"returnValueClassname" : "org.unlogged.demo.models.CustomerProfile",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703576526978,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : 575125164,
"probSerializedValue" : "eyJjdXN0b21lcmlkIjowLCJjdXN0b21lcm5hbWUiOiJzdHJpbmciLCJkYXRlb2ZiaXJ0aCI6InN0cmluZyIsImVtYWlsIjoic3RyaW5nIiwiY29udGFjdG51bWJlciI6InN0cmluZyIsImFkZHJlc3MiOiJzdHJpbmciLCJyZWZlcnJhbGNvZGVzIjpbInN0cmluZyJdfQ==",
"mockIds" : [ "9f0cdb81-0b43-40cd-9db6-157ae17a44fb" ],
"exception" : false,
"method" : {
"name" : "getCustomerProfile",
"signature" : "(J)Lorg/unlogged/demo/models/CustomerProfile;",
"className" : "org.unlogged.demo.controller.CustomerController",
"methodHash" : 1335237380
}
} ],
"org.unlogged.demo.controller.CustomerController#removeCustomerProfile#(J)Lorg/unlogged/demo/models/CustomerProfile;" : [ {
"lineNumbers" : [ 34 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"id" : "e1fdb2b4-9331-464e-ae75-3b4481d8d836",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "63f07c94-0ce0-4d87-a154-8b89489cd5d4",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "ea9c623d-a918-4756-92ca-51e0447dff8e",
"name" : "remove customer 0",
"description" : "should pass",
"methodArguments" : [ "0" ],
"returnValue" : "{\"customerid\":0,\"customername\":\"string\",\"dateofbirth\":\"string\",\"email\":\"string\",\"contactnumber\":\"string\",\"address\":\"string\",\"referralcodes\":[\"string\"]}",
"returnValueClassname" : "org.unlogged.demo.models.CustomerProfile",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703576671889,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : 278379461,
"probSerializedValue" : "eyJjdXN0b21lcmlkIjowLCJjdXN0b21lcm5hbWUiOiJzdHJpbmciLCJkYXRlb2ZiaXJ0aCI6InN0cmluZyIsImVtYWlsIjoic3RyaW5nIiwiY29udGFjdG51bWJlciI6InN0cmluZyIsImFkZHJlc3MiOiJzdHJpbmciLCJyZWZlcnJhbGNvZGVzIjpbInN0cmluZyJdfQ==",
"mockIds" : [ "4afb5b6f-4229-45dd-b383-a071fce7b9b2" ],
"exception" : false,
"method" : {
"name" : "removeCustomerProfile",
"signature" : "(J)Lorg/unlogged/demo/models/CustomerProfile;",
"className" : "org.unlogged.demo.controller.CustomerController",
"methodHash" : 851606882
}
} ]
},
"declaredMockMap" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"classname" : "org.unlogged.demo.controller.FutureController",
"storedCandidateMap" : {
"org.unlogged.demo.controller.FutureController#getFutureResultOptional#(Ljava/lang/String;)Ljava/lang/String;" : [ {
"lineNumbers" : [ 21, 22 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "\"string\"",
"id" : "049cde15-8ab6-4642-936b-6094ae2a1de6",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "fb613ff0-61f2-4db1-a971-ac9165fd415e",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "28c9f0e8-93ba-4dd7-aefc-ec83b61fc6c7",
"name" : "fc - optional case",
"description" : "optional case - should pass",
"methodArguments" : [ "\"string\"" ],
"returnValue" : "\"string\"",
"returnValueClassname" : "java.lang.Object",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703578982359,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : -283565333,
"probSerializedValue" : "InN0cmluZyI=",
"mockIds" : [ "737f11ba-f132-4d64-b9ba-23c857f16e9b" ],
"exception" : false,
"method" : {
"name" : "getFutureResultOptional",
"signature" : "(Ljava/lang/String;)Ljava/lang/String;",
"className" : "org.unlogged.demo.controller.FutureController",
"methodHash" : -1498505688
}
} ]
},
"declaredMockMap" : { }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"classname" : "org.unlogged.demo.controller.ProtoController",
"storedCandidateMap" : {
"org.unlogged.demo.controller.ProtoController#getAddressbook#()Lorg/unlogged/demo/protos/generated/AddressBook;" : [ {
"lineNumbers" : [ 42, 43, 44, 45 ],
"testAssertions" : {
"subAssertions" : [ {
"subAssertions" : [ ],
"expression" : "SELF",
"expectedValue" : "{\"memoizedHashCode\":0,\"memoizedSize\":-1,\"unknownFields\":{\"fields\":{}},\"people_\":[{\"memoizedHashCode\":0,\"memoizedSize\":-1,\"unknownFields\":{\"fields\":{}},\"bitField0_\":1,\"name_\":\"Amg\",\"id_\":0,\"email_\":\"\",\"phones_\":[],\"memoizedIsInitialized\":1}],\"memoizedIsInitialized\":1}",
"id" : "5191b6cc-6f25-4600-8a2c-b981f13db29e",
"assertionType" : "EQUAL",
"key" : "/"
} ],
"expression" : "SELF",
"expectedValue" : null,
"id" : "2944a6ee-cf29-497a-9869-a14251912645",
"assertionType" : "ALLOF",
"key" : null
},
"candidateId" : "31eaed49-a11c-497f-8fcb-a8ddd36aad15",
"name" : "get default address book",
"description" : "should pass",
"methodArguments" : [ ],
"returnValue" : "{\"memoizedHashCode\":0,\"memoizedSize\":-1,\"unknownFields\":{\"fields\":{}},\"people_\":[{\"memoizedHashCode\":0,\"memoizedSize\":-1,\"unknownFields\":{\"fields\":{}},\"bitField0_\":1,\"name_\":\"Amg\",\"id_\":0,\"email_\":\"\",\"phones_\":[],\"memoizedIsInitialized\":1}],\"memoizedIsInitialized\":1}",
"returnValueClassname" : "org.unlogged.demo.protos.generated.AddressBook",
"metadata" : {
"recordedBy" : "testerfresher",
"hostMachineName" : "testerfresher",
"timestamp" : 1703579022799,
"candidateStatus" : "PASSING"
},
"sessionIdentifier" : -230218422,
"probSerializedValue" : "eyJtZW1vaXplZEhhc2hDb2RlIjowLCJtZW1vaXplZFNpemUiOi0xLCJ1bmtub3duRmllbGRzIjp7ImZpZWxkcyI6e319LCJwZW9wbGVfIjpbeyJtZW1vaXplZEhhc2hDb2RlIjowLCJtZW1vaXplZFNpemUiOi0xLCJ1bmtub3duRmllbGRzIjp7ImZpZWxkcyI6e319LCJiaXRGaWVsZDBfIjoxLCJuYW1lXyI6IkFtZyIsImlkXyI6MCwiZW1haWxfIjoiIiwicGhvbmVzXyI6W10sIm1lbW9pemVkSXNJbml0aWFsaXplZCI6MX1dLCJtZW1vaXplZElzSW5pdGlhbGl6ZWQiOjF9",
"mockIds" : [ ],
"exception" : false,
"method" : {
"name" : "getAddressbook",
"signature" : "()Lorg/unlogged/demo/protos/generated/AddressBook;",
"className" : "org.unlogged.demo.controller.ProtoController",
"methodHash" : 753748090
}
} ]
},
"declaredMockMap" : { }
}
Loading

0 comments on commit b84977a

Please sign in to comment.