Question: Please write the code in Java In this assignment, we will work to better support the CRM scenarios from https://www.zoho.com/crm/resources/videos/how-to-videos/assignment-rules.html Links to an external site..
Please write the code in Java
In this assignment, we will work to better support the CRM scenarios from https://www.zoho.com/crm/resources/videos/how-to-videos/assignment-rules.html Links to an external site.. We note the common parts of the different assignment rules presented:
choosing which leads fit a particular rule
the country where the lead is located
the industry of the lead (this is based on the text at https://help.zoho.com/portal/en/kb/crm/automate-business-processes/assignment-rules/articles/set-assignment-rules#CreatingAssignment_Rules Links to an external site.), like Small/Medium Enterprise
the video mentions a default rule of picking any online user
choosing a user to assign
it can be a specific user
it can be one of a group of users, rotating among the users (like hw1 did when there are more than one user)
There are many other options, but this is an aspect of the CRM domain where we can parameterize parts of the behavior to avoid repeating the code, and where you might expect requirements to change in the future, probably by supporting more options. To handle this:
Add industry as a field of the Lead class
You can make the type just String or you can define an Enum class for valid values
This will require you to modify/add functions
Define a new class Rule. It should include:
a String instance variable (field) for the name of the rule
two Predicate instance variables, one for Lead and one for User
these are to determine true/false whether a particular Lead or User matches this rule
Predicate is defined in java.util.function.Predicate
A BiConsumer instance variable for a Lead and a User
This determines what to do if you want to execute this rule with
A method function canApply that takes a Lead and a User and returns true if both satisfy the requirements of the Rule
Use the Predicates to check this
Remember that a Predicate is an object, so you need to call its test(T) method
A method function execute that takes a Lead and a User and executes the Rule if both satisfy the requirements
Call canApply() to test the Lead and User
If the requirements are satisfied, use the BiConsumers accept() to take the correct action
The requirements for the test cases follow. You are encouraged to start running test cases before finishing all of the code. This will help you see if you are on the right track and provide an early check on whether you can write and run the test cases properly.
Define JUnit test cases to check each of the following rules:Any lead can be assigned to any online user
Include cases for both a lead being unassigned and assigned. The assertion should confirm that the lead is not re-assigned
Include a case where no user is online.
By Location, with a Specific User: Leads from a particular country must be assigned to a specific user
It is usually best to start with the good scenario that you would want to run to demo the application to a client. Here, have a lead from the desired country and have the desired user be online
Add cases with leads from the wrong country and with the desired user being offline. The assertions should confirm that assignments are not made
By Industry, with a Group of User: Leads from a particular industry are assigned to one of a group of users
Include cases where there are leads from the desired industry as well as leads from other industries
Include cases with multiple leads that show that leads are assigned to users in a round-robin order
Write code to cover these cases so they pass. [One common error people make when they start with unit tests is to write tests in a way that you know will fail. You want to get all the test cases to pass.]
For the criteria, you can choose to write classes that implement the Predicate and BiConsumer interfaces, or you can write lambdas that satisfy those interfaces, or you can choose a mix of the two approaches.
If you write lambdas, that code is graded as part of the source code vs. the test case code.
You do not need to update the main program to use rules.
To submit, attach both your unit test files and your source files include files even if you didnt make changes. This will make it easier for me to run your test cases in case you used different class or method names. It is probably best to compress the src and, if you have it, the test folder as separate compressed folders so that when downloaded there will not be a naming conflict.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
