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

Correcting instances of greeting services in test, according to the DIs #122

Open
wants to merge 2 commits into
base: profiles
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
Expand Up @@ -4,14 +4,11 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

/**
* Created by jt on 12/26/19.
*/
@Controller
public class ConstructorInjectedController {
private final GreetingService greetingService;

public ConstructorInjectedController(@Qualifier("constructorGreetingService") GreetingService greetingService) {
public ConstructorInjectedController(@Qualifier("constructorInjectedGreetingService") GreetingService greetingService) {
this.greetingService = greetingService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Created by jt on 12/26/19.
*/
@Service
public class ConstructorGreetingService implements GreetingService {
public class ConstructorInjectedGreetingService implements GreetingService {
@Override
public String sayGreeting() {
return "Hello World - Constructor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
* Created by jt on 12/27/19.
*/
@Profile("ES")
@Profile({"ES", "default"})
@Service("i18nService")
public class I18NSpanishService implements GreetingService {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Service;

/**
* Created by jt on 12/27/19.
*/
@Profile("EN")
@Service("i18nService")
public class I18nEnglishGreetingService implements GreetingService {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
spring.profiles.active=ES
#spring.profiles.active=EN
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package guru.springframework.sfgdi.controllers;

import guru.springframework.sfgdi.services.ConstructorGreetingService;
import guru.springframework.sfgdi.services.ConstructorInjectedGreetingService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -10,7 +10,7 @@ class ConstructorInjectedControllerTest {

@BeforeEach
void setUp() {
controller = new ConstructorInjectedController(new ConstructorGreetingService());
controller = new ConstructorInjectedController(new ConstructorInjectedGreetingService());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package guru.springframework.sfgdi.controllers;

import guru.springframework.sfgdi.services.ConstructorGreetingService;
import guru.springframework.sfgdi.services.PropertyInjectedGreetingService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -12,7 +12,7 @@ class PropertyInjectedControllerTest {
void setUp() {
controller = new PropertyInjectedController();

controller.greetingService = new ConstructorGreetingService();
controller.greetingService = new PropertyInjectedGreetingService();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package guru.springframework.sfgdi.controllers;

import guru.springframework.sfgdi.services.ConstructorGreetingService;
import guru.springframework.sfgdi.services.SetterInjectedGreetingService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -11,7 +11,7 @@ class SetterInjectedControllerTest {
@BeforeEach
void setUp() {
controller = new SetterInjectedController();
controller.setGreetingService(new ConstructorGreetingService());
controller.setGreetingService(new SetterInjectedGreetingService());
}

@Test
Expand Down