Sunteți pe pagina 1din 12

Evalua on details TE66-H24Y-UXFF

Created on: 2019-12-29

John Smith
 john.smith@devskiller.com

Financial expecta ons: 10000


No ce period: one month

Results overview
Test Score Score comparison Skills
SQL - 100%

83 % MYSQL - 100%

JAVA REFLECTION API - 100%


33 of 40 points Candidate has the best score.
JAVA - 77%

SPRING - 75%

SPRING BOOT - 75%

MONGODB - 75%

SPRING BOOT 2 - 75%

REST API - 75%

JAVA STREAM API - 60%


Test summary
 Test Java Showcase Test

 Invita on date 2019-12-29 13:35 UTC  Test dura on 36 minutes

 Test start date 2019-12-29 09:35 UTC  Test comple on date 2019-12-29 10:11 UTC

 Candidate IP 91.198.174.193
(Approx. loca on: Netherlands)

Answers summary
No. Page tle Dura on Score

1 min 8 / 10
#2 Sec on 1
Suggested: 5 mins 80.00 %

11 mins 10 / 10
#3 Sec on 2
Suggested: 25 mins 100.00 %

22 mins 15 / 20
#4 Sec on 3
Suggested: 30 mins 75.00 %

#5 Sec on 4 nothing
Suggested: nothing
Answers details

Sec on 1
 Dura on: 1 min (Suggested dura on: 5 mins)

Please complete the following method which will return the email of a given user using
Reflec on API

1 class User {
2
3 private final String email;
4
5 User(String email) {
6 this.email = email;
7 }
8
9 public String getEmail() {
10 return email;
11 }
12 }
13
14 public String getEmail(User user) throws Exception {
15 Method emailGetter = User.class. getDeclaredMethod ("getEmail");
16 String result = (String) emailGetter. invoke (user);
17 return result;
18 }
19

Please complete the following snippet to create a Map which maps enum name to edit
privilage

1 Map<String, Boolean> userTypeToEditPermission() {


2 return Stream. of (UserType. values() )
3 . map ( (Enum::name, UserType::hasEditPermission));
4 }
5
6 enum UserType {
7 ADMIN(true), MODERATOR(true), DEVELOPER(false);
8
9 private final boolean editPermission;
10
11 UserType(boolean editPermission) {
12 this.editPermission = editPermission;
13 }
14
15 public boolean hasEditPermission() {
16 return editPermission;
17 }
18 }

Sec on 2
 Dura on: 11 mins (Suggested dura on: 25 mins)

Database answer
Score: 10 / 10

Online Store
Database structure
You are given one table:

CREATE TABLE orders


(
order_number int PRIMARY KEY,
client varchar(20),
revenue int,
fixed_transport_cost int,
income int,
order_date date
)

Problem Statement
Select clients whose first order was placed in 2017 and calculate how much income was
genereted in 2018 (total) per each of them.

Desired output example


Clients whose first order placed in 2017 Sum of income in 2018

McDuck 5000

Pocahontas & co. 3500

Hint
Run "Validate query" to see expected results.
 CANDIDATE QUERY

select
clients.valid_client as client_name,
sum(o.income) as income
from
(select client as 'valid_client', min(order_date)
from orders
group by client
having year(min(order_date)) = '2017') clients
join orders o on o.client = clients.valid_client
where year(o.order_date) = '2018'
group by clients.valid_client

 
VALIDATION RESULT VERIFICATION TESTS

Tests failed: 0
Answer is correct
Tests passed: 4

4 verifica on tests executed

Test results
com.devskiller.sql.task.test.CandidateTest

Result Name Message

The expected data matches



ignoring order

 The result columns matches

The expected data is included in



the result

The expected data matches



including order

com.devskiller.sql.task.test.Verifica onTest

Result Name Message

verifica on: The expected data


 matches ignoring order for
CandidateTestCase
Result Name Message

verifica on: The expected data


 matches including order for
CandidateTestCase

verifica onTestCase The result


 columns should matches for
CandidateTestCase

verifica on: The expected data


 is included in the result for
CandidateTestCase

Sec on 3
 Dura on: 22 mins (Suggested dura on: 30 mins)

Code edit answer


Score: 15 / 20

Blog Engine powered by Spring Boot


This project is a simple REST applica on for serving a blog. It uses Spring Boot, Spring Data
Mongo, MongoDB and some other helper libraries.

Problem Statement
In its current state, this applica on only serves blog post details via a GET request at /post
s/{id} , where {id} is a post iden fier.

Your task is to add a comments feature. The applica on should be able to serve two new
kinds of requests:

POST at /posts/{1}/comments - this should save a new comment for the post match
ing the submitted {id}
GET at /posts/{1}/comments - this should return all comments for a post matchin
g the submitted {id}

There is a service class CommentService that must be implemented. Review that class to
gain more understanding as per the requirements. For each method, there is a javadoc
comment that describes the expected behavior.

A subset of tests are currently failing and your solu on should result in these tests passing
per the requirements presented above.

Remember that the included tests only verify the apps func onal correctness. In addi on
please remember to apply best prac ces while developing your solu on.
Feel free to create and modify files. You are also welcome to add new dependencies, just
make certain to modify the appropriate pom.xml . Do not change unit tests, however.

Please follow the conven ons used in this project.

 
AUTOMATIC EVALUATION VERIFICATION STATUS

Func onality score:

Code quality score:


14 of 18

1 of 2

Requirements not fully met

Total score: 15 of 20 points

 
VERIFICATION TESTS VIOLATIONS

Tests failed: 3 Not changed by candidate

Tests passed: 11

14 verifica on tests executed Before: 10 viola ons A er: 10 viola ons


RULES COMPLIANCE 9 SIMILARITY CHECK

95.50%
Similarity found

Not changed by candidate

Before: 95.50% Similarity Index: 31%

Test results
com.devskiller.tasks.blog.rest.CommentControllerTest
 shouldReturnFoundComments
 shouldAddComment

com.devskiller.tasks.blog.service.CommentServiceTest
 shouldAddComment
 shouldReturnAddedComment

com.devskiller.tasks.blog.service.PostServiceTest
 shouldReturnCreatedPost
 shouldReturnNullForNotExis ngPost

com.devskiller.tasks.blog.rest.PostControllerTest
 shouldReturnFoundPost

verify_pack.VerifyIntegratedCommentRestTest
 shouldReturnAddedComments
Details: java.lang.AssertionError: JSON path "$[0].comment"
Expected: is "Test content2"
but: was "Test content1"

 shouldReturnEmptyListForNewPost
 shouldReturn404ForAddCommentForNotExis ngPost
 shouldReturn404ForListForNotExis ngPost

verify_pack.VerifyMockedCommentRestTest
 shouldReturnFoundComments
 newCommentDtoShouldMatchSentContent

verify_pack.VerifyCommentServiceTest
 shouldReturnCommentsInDescendingOrder
Details: java.lang.AssertionError: Second comment should be first
Expected: hasProperty("id", "ff241cb8-cd91-4faf-8557-096e5b3bd1fb")
but: property 'id' was "3e106b8b-e5a8-4f84-8278-7f1164b3cc11"

 shouldCheckStabilityOfCommentsOrdering
Details: java.lang.AssertionError: First comment should be third
Expected: "8bd4f9c3-1cef-456c-8cf2-4522d6b3941f"
but: was "297df3ab-7b5e-46b2-adfd-04d98d909e5c"

 shouldThrowExcep onForNullPostIdWhileAdding
 shouldReturnCommentIdA erAdding
 shouldThrowExcep onForNotExis ngPostWhileAdding
 shouldReturnEmptyListForPostWithoutComments
 shouldThrowExcep onForNotExis ngPostWhileLis ng
 shouldSetCrea onDateForNewComment

Code changes
src/main/java/com/devskiller/tasks/blog/model/Post.java
2 2
3 3 import java.time.LocalDateTime;
4 +import java.util.ArrayList;
5 +import java.util.List;
4 6
5 7 import org.springframework.data.annotation.Id;
6 8
9 +import com.devskiller.tasks.blog.model.dto.CommentDto;
10 +
7 11 public class Post {
8 12
...
16 20 private LocalDateTime creationDate;
17 21
22 + private List<CommentDto> comments = new ArrayList<>();
23 +
18 24 public String getTitle() {
19 25 return title;
...
48 54 }
49 55
56 + public List<CommentDto> getComments() {
57 + return comments;
58 + }
59 +
60 + public void addComment(CommentDto comments) {
61 + this.comments.add(comments);
62 + }
50 63 }

src/main/java/com/devskiller/tasks/blog/rest/CommentCont…
1 +package com.devskiller.tasks.blog.rest;
2 +
3 +import java.util.List;
4 +
5 +import org.springframework.http.HttpStatus;
6 +import org.springframework.stereotype.Controller;
7 +import org.springframework.web.bind.annotation.GetMapping;
8 +import org.springframework.web.bind.annotation.PathVariable;
9 +import org.springframework.web.bind.annotation.PostMapping;
10 +import org.springframework.web.bind.annotation.RequestBody;
11 +import org.springframework.web.bind.annotation.RequestMapping;
12 +import org.springframework.web.bind.annotation.ResponseStatus;
13 +import org.springframework.web.bind.annotation.RestController;
14 +
15 +import com.devskiller.tasks.blog.model.dto.CommentDto;
16 +import com.devskiller.tasks.blog.model.dto.NewCommentDto;
17 +import com.devskiller.tasks.blog.service.CommentService;
18 +
19 +@Controller
20 +@RestController
21 +@RequestMapping("/posts/{postId}/comments")
22 +public class CommentController {
23 +
24 + private final CommentService commentService;
25 +
26 + public CommentController(CommentService commentService) {
27 + this.commentService = commentService;
28 + }
29 +
30 + @GetMapping
31 + List<CommentDto> getComment(@PathVariable String postId) {
32 + return commentService.getCommentsForPost(postId);
33 + }
34 +
35 + @PostMapping
36 + @ResponseStatus(HttpStatus.CREATED)
37 + public void addComment(@PathVariable String postId, @RequestBody NewCommentDto
38 + newComment.setPostId(postId);
39 + commentService.addComment(newComment);
40 + }
41 +
42 +}

src/main/java/com/devskiller/tasks/blog/rest/RestResponse…
1 +package com.devskiller.tasks.blog.rest;
2 +
3 +import org.springframework.http.ResponseEntity;
4 +import org.springframework.web.bind.annotation.ControllerAdvice;
5 +import org.springframework.web.bind.annotation.ExceptionHandler;
6 +import org.springframework.web.context.request.WebRequest;
7 +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcept
8 +
9 +@ControllerAdvice
10 +public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHa
11 +
12 + @ExceptionHandler(IllegalArgumentException.class)
13 + protected ResponseEntity<Void> handleResourceNotFound(RuntimeException ex, Web
14 + return ResponseEntity.notFound().build();
15 + }
16 +}
0 17 \ No newline at end of file

src/main/java/com/devskiller/tasks/blog/service/CommentS…
1 1 package com.devskiller.tasks.blog.service;
2 2
3 +import java.time.LocalDateTime;
3 4 import java.util.List;
5 +import java.util.UUID;
4 6
5 7 import org.springframework.stereotype.Service;
6 8
9 +import com.devskiller.tasks.blog.model.Post;
7 10 import com.devskiller.tasks.blog.model.dto.CommentDto;
8 11 import com.devskiller.tasks.blog.model.dto.NewCommentDto;
12 +import com.devskiller.tasks.blog.repository.PostRepository;
9 13
10 14 @Service
11 15 public class CommentService {
12 16
17 + private final PostRepository postRepository;
18 +
19 + public CommentService(PostRepository postRepository) {
20 + this.postRepository = postRepository;
21 + }
22 +
13 23 /**
14 24 * Returns a list of all comments for a blog post with passed id.
...
20 30 */
21 31 public List<CommentDto> getCommentsForPost(String postId) {
22 - throw new UnsupportedOperationException();
32 + return postRepository.findById(postId)
33 + .map(Post::getComments)
34 + .orElseThrow(IllegalArgumentException::new);
23 35 }
24 36
...
32 44 */
33 45 public String addComment(NewCommentDto newCommentDto) {
34 - throw new UnsupportedOperationException();
46 + CommentDto comment = new CommentDto(UUID.randomUUID().toString(), newComm
47 + newCommentDto.getAuthor(), LocalDateTime.now());
48 + postRepository.save(
49 + postRepository.findById(newCommentDto.getPostId())
50 + .map(p -> {
51 + p.addComment(comment);
52 + return p;
53 + })
54 + .orElseThrow(IllegalArgumentException::new));
55 + return comment.getId();
35 56 }
36 57 }

Sec on 4
Input: No ce period

one month

Input: Expected monthly salary in EUR

6000

S-ar putea să vă placă și