Skip to content
Permalink
Browse files
Refactoring API Naming Conventions
  • Loading branch information
ebenezergraham committed Jun 7, 2019
1 parent 339f83f commit 286c3143ba086cd0862ba5ced403fc7c0571a659
Showing 16 changed files with 72 additions and 271 deletions.
@@ -31,51 +31,56 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@SuppressWarnings("unused")
@FeignClient(value = "notification-v1", path = "/notification/v1", configuration = CustomFeignClientsConfiguration.class)
public interface NotificationManager {

@RequestMapping(
value = "/configuration/sms/active",
value = "/configuration/sms",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
SMSConfiguration findAllActiveSMSConfigurationEntities();
List<SMSConfiguration> findAllSMSConfigurations();

@RequestMapping(
value = "/configuration/email/active",
value = "/configuration/email",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
EmailConfiguration findAllActiveEmailConfigurationEntities();
List<EmailConfiguration> findAllEmailConfigurations();

@RequestMapping(
value = "/configuration/sms/create",
value = "/configuration/sms",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.NOT_FOUND, exception = ConfigurationNotFoundException.class)
@ThrowsException(status = HttpStatus.CONFLICT, exception = ConfigurationAlreadyExistException.class)
})
String createSMSConfiguration(final SMSConfiguration smsConfiguration);

@RequestMapping(
value = "/configuration/email/create",
value = "/configuration/email",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.CONFLICT, exception = ConfigurationAlreadyExistException.class)
})
String createEmailConfiguration(final EmailConfiguration emailConfiguration);

@RequestMapping(
value = "/template/create",
value = "/template",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
@ThrowsExceptions({
@ThrowsException(status = HttpStatus.UNPROCESSABLE_ENTITY, exception = TemplateAlreadyExistException.class)
@ThrowsException(status = HttpStatus.CONFLICT, exception = TemplateAlreadyExistException.class)
})
String createTemplate(final Template template);

@@ -95,32 +100,31 @@ public interface NotificationManager {
)
EmailConfiguration findEmailConfigurationByIdentifier(@PathVariable("identifier") final String identifier);

@RequestMapping(value = "/configuration/sms/update",
@RequestMapping(value = "/configuration/sms",
method = RequestMethod.PUT,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
void updateSMSConfiguration(final SMSConfiguration smsConfiguration);

@RequestMapping(value = "/configuration/email/update",
@RequestMapping(value = "/configuration/email",
method = RequestMethod.PUT,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
void updateEmailConfiguration(final EmailConfiguration emailConfiguration);

@RequestMapping(value = "/configuration/sms/delete/{identifier}",
@RequestMapping(value = "/configuration/sms/{identifier}",
method = RequestMethod.DELETE,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
void deleteSMSConfiguration(@PathVariable("identifier") final String identifier);

@RequestMapping(value = "/configuration/email/delete/{identifier}",
@RequestMapping(value = "/configuration/email/{identifier}",
method = RequestMethod.DELETE,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
void deleteEmailConfiguration(@PathVariable("identifier") final String identifier);

}
@@ -71,7 +71,7 @@ public void setUp() {
public void documentCreateEmailConfiguration() throws Exception {
final EmailConfiguration emailConfiguration = DomainObjectGenerator.emailConfiguration();

this.mockMvc.perform(post("/configuration/email/create")
this.mockMvc.perform(post("/configuration/email")
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(emailConfiguration)))
@@ -149,7 +149,7 @@ public void documentUpdateEmailConfiguration() throws Exception {

super.eventRecorder.wait(NotificationEventConstants.UPDATE_EMAIL_CONFIGURATION, newRandomConfiguration.getIdentifier());

this.mockMvc.perform(put("/configuration/sms/update")
this.mockMvc.perform(put("/configuration/sms")
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(newRandomConfiguration)))
@@ -180,7 +180,7 @@ public void documentDeleteEmailConfiguration() throws Exception {
notificationManager.createEmailConfiguration(randomConfiguration);
super.eventRecorder.wait(NotificationEventConstants.DELETE_EMAIL_CONFIGURATION, randomConfiguration.getIdentifier());

this.mockMvc.perform(delete("/configuration/email/delete/" + randomConfiguration.getIdentifier())
this.mockMvc.perform(delete("/configuration/email/" + randomConfiguration.getIdentifier())
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
@@ -73,7 +73,7 @@ public void setUp() {
public void documentCreateSMSConfiguration() throws Exception {
final SMSConfiguration randomSMSConfiguration = DomainObjectGenerator.smsConfiguration();

this.mockMvc.perform(post("/configuration/sms/create")
this.mockMvc.perform(post("/configuration/sms")
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(randomSMSConfiguration)))
@@ -135,7 +135,7 @@ public void documentUpdateSMSConfiguration() throws Exception {

notificationManager.updateSMSConfiguration(randomSMSConfiguration);

this.mockMvc.perform(put("/configuration/sms/update")
this.mockMvc.perform(put("/configuration/sms")
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE)
.content(gson.toJson(randomSMSConfiguration)))
@@ -160,8 +160,7 @@ public void documentDeleteSMSConfiguration() throws Exception {

super.eventRecorder.wait(NotificationEventConstants.POST_SMS_CONFIGURATION, randomSMSConfiguration.getIdentifier());

System.out.println(randomSMSConfiguration.getIdentifier());
this.mockMvc.perform(delete("/configuration/sms/delete/" + randomSMSConfiguration.getIdentifier())
this.mockMvc.perform(delete("/configuration/sms/" + randomSMSConfiguration.getIdentifier())
.accept(MediaType.APPLICATION_JSON_VALUE)
.contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
@@ -25,15 +25,13 @@
import org.apache.fineract.cn.notification.api.v1.client.ConfigurationNotFoundException;
import org.apache.fineract.cn.notification.api.v1.domain.EmailConfiguration;
import org.apache.fineract.cn.notification.api.v1.events.NotificationEventConstants;
import org.apache.fineract.cn.notification.service.internal.importer.TemplateImporter;
import org.apache.fineract.cn.notification.service.internal.service.EmailService;
import org.apache.fineract.cn.notification.util.DomainObjectGenerator;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

@@ -105,7 +103,7 @@ public void shouldCreateAndRetrieveEmailConfigurationEntity() throws Interrupted
Assert.assertTrue(this.eventRecorder.wait(NotificationEventConstants.POST_EMAIL_CONFIGURATION, emailConfiguration.getIdentifier()));

EmailConfiguration sampleRetrieved = notificationManager.findEmailConfigurationByIdentifier(emailConfiguration.getIdentifier());
Assert.assertEquals(sampleRetrieved.getIdentifier(),emailConfiguration.getIdentifier());
Assert.assertEquals(sampleRetrieved,emailConfiguration);
}

@Test
@@ -117,7 +115,7 @@ public void checkEmailConfigurationEntityExist() throws InterruptedException {
}

@Test
public void shouldFindActiveGateway() {
public void shouldFindDefaultGateway() {
this.logger.info("Find Active Gateway");
Assert.assertNotNull(this.emailService.getDefaultEmailConfigurationEntity());
}
@@ -49,13 +49,13 @@

@SuppressWarnings("unused")
@Component
public class EventListener {
public class ConfigurationEventListener {
private final EventRecorder eventRecorder;
private final Logger logger;

@Autowired
public EventListener(final EventRecorder eventRecorder,
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
public ConfigurationEventListener(final EventRecorder eventRecorder,
@Qualifier(ServiceConstants.LOGGER_NAME) final Logger logger) {
this.logger = logger;
this.eventRecorder = eventRecorder;
}
@@ -21,21 +21,11 @@
public interface ServiceConstants {
String LOGGER_NAME = "notification-logger";

String CUSTOMER_SERVICE_NAME ="customer-v1";
String ACCOUNT_SERVICE_NAME ="account-v1";
String PORTFOLIO_SERVICE_NAME ="porfolio-v1";

String MAIL_TRANSPORT_PROTOCOL_PROPERTY = "mail.transport.protocol";
String MAIL_TRANSPORT_PROTOCOL_VALUE = "smtp";
String MAIL_SMTP_AUTH_PROPERTY = "mail.smtp.auth";
String MAIL_SMTP_AUTH_VALUE = "true";
String MAIL_SMTP_STARTTLS_ENABLE_PROPERTY = "mail.smtp.starttls.enable";
String MAIL_SMTP_STARTTLS_ENABLE_VALUE = "true";
String MAIL_SMTP_TIMEOUT_PROPERTY = "";

String GOOGLE_MAIL_SERVER = "smtp.gmail.com";
String YAHOO_MAIL_SERVER = "smtp.mail.yahoo.com";

String MAIL_SMTP_TIMEOUT_PROPERTY = "";
String MAIL_SMTP_TIMEOUT_VALUE = "";

}
@@ -18,22 +18,17 @@
*/
package org.apache.fineract.cn.notification.service.internal.config;

import org.apache.activemq.command.ActiveMQTopic;
import org.apache.activemq.jms.pool.PooledConnectionFactory;
import org.apache.activemq.spring.ActiveMQConnectionFactory;
import org.apache.fineract.cn.anubis.config.EnableAnubis;
import org.apache.fineract.cn.async.config.EnableAsync;
import org.apache.fineract.cn.cassandra.config.EnableCassandra;
import org.apache.fineract.cn.command.config.EnableCommandProcessing;
import org.apache.fineract.cn.customer.api.v1.client.CustomerManager;
import org.apache.fineract.cn.identity.api.v1.client.IdentityManager;
import org.apache.fineract.cn.lang.ApplicationName;
import org.apache.fineract.cn.lang.config.EnableServiceException;
import org.apache.fineract.cn.lang.config.EnableTenantContext;
import org.apache.fineract.cn.mariadb.config.EnableMariaDB;
import org.apache.fineract.cn.notification.service.ServiceConstants;
import org.apache.fineract.cn.notification.service.internal.identity.CustomerPermittedClient;
import org.apache.fineract.cn.permittedfeignclient.config.EnablePermissionRequestingFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -71,12 +66,10 @@
@EnableServiceException
@EnableJms
@EnableConfigurationProperties
@EnablePermissionRequestingFeignClient(feignClasses = {CustomerPermittedClient.class})
@EnableFeignClients(
clients = {
CustomerManager.class,
IdentityManager.class,
CustomerPermittedClient.class
}
)
@ComponentScan({
@@ -85,7 +78,6 @@
"org.apache.fineract.cn.notification.service.internal",
"org.apache.fineract.cn.notification.service.internal.repository",
"org.apache.fineract.cn.notification.service.internal.command.handler",
"org.apache.fineract.cn.notification.service.internal.identity",
"org.apache.fineract.cn.notification.service.internal.config",
}
)
@@ -107,15 +99,6 @@ public void configurePathMatch(final PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(Boolean.FALSE);
}

@Bean
public PooledConnectionFactory pooledConnectionFactory() {
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory();
activeMQConnectionFactory.setBrokerURL(this.environment.getProperty("activemq.brokerUrl","vm://localhost?broker.persistent=false"));
pooledConnectionFactory.setConnectionFactory(activeMQConnectionFactory);
return pooledConnectionFactory;
}

@Bean
public JmsListenerContainerFactory jmsListenerContainerFactory(PooledConnectionFactory jmsFactory) {
final DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
@@ -129,16 +112,6 @@ public JmsListenerContainerFactory jmsListenerContainerFactory(PooledConnectionF
return factory;
}

@Bean
public JmsTemplate jmsTemplate(ApplicationName applicationName, PooledConnectionFactory jmsFactory) {
ActiveMQTopic activeMQTopic = new ActiveMQTopic(applicationName.toString());
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setPubSubDomain(true);
jmsTemplate.setConnectionFactory(jmsFactory);
jmsTemplate.setDefaultDestination(activeMQTopic);
return jmsTemplate;
}

@Bean
public SpringTemplateEngine springTemplateEngine() {
SpringTemplateEngine templateEngine = new SpringTemplateEngine();

This file was deleted.

0 comments on commit 286c314

Please sign in to comment.