📍Use lombok, reformat, and optimize the code (#1560)
* Use lombok, reformat, and optimize the code * Fix merge conflicts and some sonar issues Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
@ -29,7 +29,6 @@ package com.iluwatar.business.delegate;
|
||||
public class BusinessDelegate {
|
||||
|
||||
private BusinessLookup lookupService;
|
||||
private BusinessService businessService;
|
||||
private ServiceType serviceType;
|
||||
|
||||
public void setLookupService(BusinessLookup businessLookup) {
|
||||
@ -41,7 +40,7 @@ public class BusinessDelegate {
|
||||
}
|
||||
|
||||
public void doTask() {
|
||||
businessService = lookupService.getBusinessService(serviceType);
|
||||
BusinessService businessService = lookupService.getBusinessService(serviceType);
|
||||
businessService.doProcessing();
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,12 @@
|
||||
|
||||
package com.iluwatar.business.delegate;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* Class for performing service lookups.
|
||||
*/
|
||||
@Setter
|
||||
public class BusinessLookup {
|
||||
|
||||
private EjbService ejbService;
|
||||
@ -45,12 +48,4 @@ public class BusinessLookup {
|
||||
return jmsService;
|
||||
}
|
||||
}
|
||||
|
||||
public void setJmsService(JmsService jmsService) {
|
||||
this.jmsService = jmsService;
|
||||
}
|
||||
|
||||
public void setEjbService(EjbService ejbService) {
|
||||
this.ejbService = ejbService;
|
||||
}
|
||||
}
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.business.delegate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Service EJB implementation.
|
||||
*/
|
||||
@Slf4j
|
||||
public class EjbService implements BusinessService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(EjbService.class);
|
||||
|
||||
@Override
|
||||
public void doProcessing() {
|
||||
LOGGER.info("EjbService is now processing");
|
||||
|
@ -23,16 +23,14 @@
|
||||
|
||||
package com.iluwatar.business.delegate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* Service JMS implementation.
|
||||
*/
|
||||
@Slf4j
|
||||
public class JmsService implements BusinessService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(JmsService.class);
|
||||
|
||||
@Override
|
||||
public void doProcessing() {
|
||||
LOGGER.info("JmsService is now processing");
|
||||
|
@ -28,5 +28,6 @@ package com.iluwatar.business.delegate;
|
||||
*/
|
||||
public enum ServiceType {
|
||||
|
||||
EJB, JMS
|
||||
EJB,
|
||||
JMS
|
||||
}
|
||||
|
@ -35,19 +35,17 @@ import static org.mockito.Mockito.verify;
|
||||
* tiers. By using the pattern we gain loose coupling between the tiers. The Business Delegate
|
||||
* encapsulates knowledge about how to locate, connect to, and interact with the business objects
|
||||
* that make up the application.
|
||||
*
|
||||
*
|
||||
* <p>Some of the services the Business Delegate uses are instantiated directly, and some can be
|
||||
* retrieved through service lookups. The Business Delegate itself may contain business logic too
|
||||
* potentially tying together multiple service calls, exception handling, retrying etc.
|
||||
*/
|
||||
public class BusinessDelegateTest {
|
||||
class BusinessDelegateTest {
|
||||
|
||||
private EjbService ejbService;
|
||||
|
||||
private JmsService jmsService;
|
||||
|
||||
private BusinessLookup businessLookup;
|
||||
|
||||
private BusinessDelegate businessDelegate;
|
||||
|
||||
/**
|
||||
@ -59,7 +57,7 @@ public class BusinessDelegateTest {
|
||||
ejbService = spy(new EjbService());
|
||||
jmsService = spy(new JmsService());
|
||||
|
||||
businessLookup = spy(new BusinessLookup());
|
||||
BusinessLookup businessLookup = spy(new BusinessLookup());
|
||||
businessLookup.setEjbService(ejbService);
|
||||
businessLookup.setJmsService(jmsService);
|
||||
|
||||
@ -73,7 +71,7 @@ public class BusinessDelegateTest {
|
||||
* service and makes the service call.
|
||||
*/
|
||||
@Test
|
||||
public void testBusinessDelegate() {
|
||||
void testBusinessDelegate() {
|
||||
|
||||
// setup a client object
|
||||
var client = new Client(businessDelegate);
|
||||
|
Reference in New Issue
Block a user