The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

markandirene (14) [Avatar] Offline
#1
Hello

1)
@Controller
public class HomeController {
public static final int DEFAULT_SPITTLES_PER_PAGE = 25;
private SpitterService spitterService;
@Inject
public HomeController(SpitterService spitterService) {
this.spitterService = spitterService;
}

Could the @Inject annotation have been specified on the private instance variable:

@Inject
private SpitterService spitterService;

And drop the Contructor as a zero-lenth contructor is created automatically

2) Does the @Controller annotation give anything above and beyond the @Component annotation like @Repository?

3) Mockito

Suppose I had defined @Autowired on the private variable in HomeController:
@Autowired
private SpitterService spitterService;

public HomeController(){}

How would I mock the SpitterService in HomeControllerTest and inject it into the HomeController?

Thanks

Mark