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

endpoint greeter controller and tested #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package tv.codely.mooc.controller.greeter;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public final class GreeterGetController {

@RequestMapping("/greeter")
public HashMap<String, String> index(@RequestParam String name) {
HashMap<String, String> resp = new HashMap<>();
String greet = "hello " + name;
resp.put("response", greet);

return resp;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tv.codely.mooc.controller.greeter;

import org.junit.jupiter.api.Test;
import tv.codely.mooc.controller.RequestTestCase;

public final class GreeterGetControllerTest extends RequestTestCase {
@Test
public void it_should_get_a_greeter_response() throws Exception {
this.getRequest("/greeter?name=pepe", 200, "{'response': 'hello pepe'}");
}
}