Skip to content
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
6 changes: 4 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Java CI with Gradle

on:
push:
branches: [ "main" ]
branches:
- '**'
pull_request:
branches: [ "main" ]
branches:
- '**'

jobs:
build:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ Open Swagger docs: http://localhost:8080/swagger-ui.html
3. **Pull Request Process**
- Create a PR from your task branch to your personal feature branch
- Assign the following reviewers to your PR:
- https://github.com/trioletas
- https://github.com/algorithm108
- https://github.com/IgorGursky
- https://github.com/trioletas (Oleg)
- https://github.com/algorithm108 (Alexey)
- https://github.com/IgorGursky (Igor)
- https://github.com/Melancholic (Andrey)

### 📝 Available Tasks

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package lv.ctco.springboottemplate.features.greeting;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/** REST controller for generation of greeting messages */
@RestController
@RequestMapping("/api/greeting")
@Tag(name = "Greeting Controller", description = "Greeting endpoints")
public class GreetingController {
private final GreetingService greetingService;

private GreetingController(GreetingService greetingService) {
this.greetingService = greetingService;
}

@GetMapping
@Operation(summary = "Get greeting with pending tasks count")
public String getGreeting() {
return greetingService.greet();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package lv.ctco.springboottemplate.features.greeting;

import lv.ctco.springboottemplate.features.todo.TodoService;
import org.springframework.stereotype.Service;

/** Service layer for greeting messages */
@Service
public class GreetingService {
private final TodoService todoService;

private GreetingService(TodoService todoService) {
this.todoService = todoService;
}

public String greet() {
long pendingItemsCount =
todoService.getAllTodos().stream().filter(todo -> !todo.completed()).count();

return "Hello from Spring! You have " + pendingItemsCount + " open tasks.";
Copy link
Collaborator

Choose a reason for hiding this comment

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

How do you think can we also handle plural/singular form of "task" ? 1 task, 2 tasks e.t.c.

}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package lv.ctco.springboottemplate.features.greeting;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import java.util.List;
import lv.ctco.springboottemplate.features.todo.Todo;
import lv.ctco.springboottemplate.features.todo.TodoRepository;
import lv.ctco.springboottemplate.features.todo.TodoService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.TestConstructor;
import org.testcontainers.containers.MongoDBContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
Expand All @@ -15,13 +26,10 @@
* <p>Initially marked {@link Disabled} to be enabled by the developer after implementation.
*/
@SpringBootTest
@Disabled("Enable after implementing GreetingService using TodoService")
@Testcontainers
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL)
class GreetingServiceIntegrationTest {

/*

@Container static MongoDBContainer mongoDBContainer = new MongoDBContainer("mongo:6.0.8");

@DynamicPropertySource
Expand Down Expand Up @@ -94,5 +102,4 @@ void should_ignore_null_todos_or_null_completed_flags() {
// then
assertThat(message).contains("1 open task");
}
*/
}