Skip to content

Conversation

@github-classroom
Copy link
Contributor

@github-classroom github-classroom bot commented May 6, 2024

👋! GitHub Classroom created this pull request as a place for your teacher to leave feedback on your work. It will update automatically. Don’t close or merge this pull request, unless you’re instructed to do so by your teacher.
In this pull request, your teacher can leave comments and feedback on your code. Click the Subscribe button to be notified if that happens.
Click the Files changed or Commits tab to see all of the changes pushed to main since the assignment started. Your teacher can see this too.

Notes for teachers

Use this PR to leave feedback. Here are some tips:

  • Click the Files changed tab to see all of the changes pushed to main since the assignment started. To leave comments on specific lines of code, put your cursor over a line of code and click the blue + (plus sign). To learn more about comments, read “Commenting on a pull request”.
  • Click the Commits tab to see the commits pushed to main. Click a commit to see specific changes.
  • If you turned on autograding, then click the Checks tab to see the results.
  • This page is an overview. It shows commits, line comments, and general comments. You can leave a general comment below.
    For more information about this pull request, read “Leaving assignment feedback in GitHub”.

Subscribed: @ManoolK

@ManoolK
Copy link
Collaborator

ManoolK commented May 13, 2024

I tried to implement Queueable Apex for this work and to bulkify upsert(update) but it didn't work, because the HttpCalloutMock returns only one result and the DummyJSON_Id__c field is unique.

@ManoolK
Copy link
Collaborator

ManoolK commented May 15, 2024

I didn't stop thinking about bulkification and finally implemented an alternative variant and added it to another pull request.
Could you please give me your feedback on it?

Copy link

@walters954 walters954 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good job. Your code is excellent.
I'll challenge you to write an additional test cases implementing additional mock calls.

*/
public override void afterUpdate() {
for (Contact cont : newConts) {
if (Integer.valueOf(cont.DummyJSON_Id__c) > 100 && !System.isFuture()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also consider adding an additional validation on the DummyJSON_Last_Updated__c field.

List<String> dummyJSONIdList = new List<String>();
for (Contact cont : newConts) {
if (cont.DummyJSON_Id__c == null) {
cont.DummyJSON_Id__c = String.valueOf(Math.round(Math.random() * 100));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

HttpRequest request = new HttpRequest();
// Set the endpoint URL. Use direct URL or for best practices use Named Credential.

request.setEndpoint('callout:DummyJsonUser' + '/' + dummyUserId);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +167 to +170
valuesMap.put('firstName', String.isNotBlank(cont.FirstName) ? cont.FirstName : 'unknown');
valuesMap.put('lastName', String.isNotBlank(cont.LastName) ? cont.LastName : 'unknown');
valuesMap.put('email', String.isNotBlank(cont.Email) ? cont.Email : 'unknown');
valuesMap.put('phone', String.isNotBlank(cont.Phone) ? cont.Phone : 'unknown');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work catching these values if they are empty.
Putting unknown for the email may cause an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants