Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deny #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Deny #1

wants to merge 3 commits into from

Conversation

Denywiryk
Copy link

The two features worked as per the readme and i tried to attempt feature three , and only one test passed

@SDiamante13
Copy link

Always include a .gitignore file in all of your projects. You can base it off of this one: https://github.com/SDiamante13/music-friends-backend/blob/main/.gitignore

Copy link

@SDiamante13 SDiamante13 left a comment

Choose a reason for hiding this comment

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

Great job! You're almost there!

@GetMapping("/greetUser")
public String helloUser() {

return "hello " + userService.helloUser();

Choose a reason for hiding this comment

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

The point of this feature was to be able to accept a name and greet that person. You should not hard-code Joe into your app. Have it work for any name the consumer passes to you.

User user;


public UserService(User user) { this.user = user;

Choose a reason for hiding this comment

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

User is a model class that frequently changes so it should not be injected into this class. Instead you would want it to be an input to a method.

return "Hello My Friend !";}

public String helloUser() {
user.setName("Joe");

Choose a reason for hiding this comment

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

instead of setting the name to Joe, pass in the name in the method



class UserServiceTest {
private UserService userServiceUnderTest;

Choose a reason for hiding this comment

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

just userService here is clear enough

Suggested change
private UserService userServiceUnderTest;
private UserService userService;

void shouldReturnStringHellowWorld(){
//THIS IS FOR J-UNIT 5 JUPITER
//given
String hellow="Hello My Friend !";

Choose a reason for hiding this comment

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

Choose a better name for the variable. Tests should be easy to understand

Suggested change
String hellow="Hello My Friend !";
String expectedMessage="Hello My Friend !";

//given
String hellow="Hello My Friend !";
//when
String stringValidity =userServiceUnderTest.helloMessage();

Choose a reason for hiding this comment

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

Suggested change
String stringValidity =userServiceUnderTest.helloMessage();
String actualMessage =userServiceUnderTest.helloMessage();

}
@Test
void shouldReturnStringHellowWorldPlusUserName(){
user.setName("Joe");

Choose a reason for hiding this comment

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

Try applying my advice about passing in the user into the method and try testing this again.

@RestController
public class UserMainController {

@Autowired

Choose a reason for hiding this comment

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

Suggested change
@Autowired

…s/UserService.java

Co-authored-by: Steven Diamante <steven4@vt.edu>
@Denywiryk
Copy link
Author

Denywiryk commented May 15, 2022 via email

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.

2 participants