Skip to content

Commit

Permalink
Merge pull request #108 from ValentinTyhonov/generateAndPublish
Browse files Browse the repository at this point in the history
Fixed issue in /generateAndPublish endpoint
  • Loading branch information
ValentinTyhonov authored Mar 15, 2018
2 parents 344e80b + 9922ef8 commit 4433563
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 141 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

## 0.5.5
- Fixed generate service link in /generateAndPublish endpoint
- Added few messages in case error in generate happen
- Uplifted semantics version to 0.4.0

## 0.5.4
- Added swagger for publish service
- Changed year in copyright headers from 2017 to 2018
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# RemRem Publish
# Eiffel REMReM Publish

[![Build Status](https://travis-ci.org/Ericsson/eiffel-remrem-publish.svg?branch=master)](https://travis-ci.org/Ericsson/eiffel-remrem-publish)
[![Coverage Status](https://coveralls.io/repos/github/Ericsson/eiffel-remrem-publish/badge.svg?branch=master)](https://coveralls.io/github/Ericsson/eiffel-remrem-publish?branch=master)
[![](https://jitpack.io/v/Ericsson/eiffel-remrem-publish.svg)](https://jitpack.io/#Ericsson/eiffel-remrem-publish)


RemRem Publish is a microservice allowing sending of messages to a topic based exchange on a RabbitMQ Server. It has an endPoint that must be called a relative link
REMReM Publish is a microservice allowing sending of messages to a topic based exchange on a RabbitMQ Server. It has endpoints that must be called as a relative links.

## Documentation
Further documentation is provided at the following link: http://ericsson.github.io/eiffel-remrem-publish



__IMPORTANT NOTICE:__ The contents of this repository currectly reflect a __DRAFT__. The Eiffel framework has been used in production within Ericsson for several years to great effect; what is presented here is a revision and evolution of that framework - an evolution that is currently ongoing. In other words, anything in this repository should be regarded as tentative and subject to change. It is published here to allow early access and trial and to solicit early feedback.
__IMPORTANT NOTICE:__ The contents of this repository currently reflect a __DRAFT__. The Eiffel framework has been used in production within Ericsson for several years to great effect; what is presented here is a revision and evolution of that framework - an evolution that is currently ongoing. In other words, anything in this repository should be regarded as tentative and subject to change. It is published here to allow early access and trial and to solicit early feedback.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ subprojects {
apply plugin: 'java'

//Latest version for publish
version = "0.5.4"
version = "0.5.5"

//Declare where to find the dependencies of project here
repositories {
Expand Down Expand Up @@ -113,7 +113,7 @@ subprojects {
compile 'com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.7'
//For publishing eiffel2.0 events

compile("com.github.Ericsson:eiffel-remrem-semantics:0.3.8"){
compile("com.github.Ericsson:eiffel-remrem-semantics:0.4.0"){

exclude group: 'org.apache.commons'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# properties for server used to generate messages
generate.server.host: 127.0.0.1
generate.server.port: 8080
generate.server.appName: generate

#Add rabbitmq properties for other protocols

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
import org.mockito.InjectMocks;
import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import static org.mockito.Mockito.*;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

import com.ericsson.eiffel.remrem.publish.controller.ProducerController;
import com.ericsson.eiffel.remrem.publish.helper.RMQHelper;
import com.ericsson.eiffel.remrem.publish.service.MessageService;
import com.ericsson.eiffel.remrem.publish.service.SendResult;
Expand All @@ -53,11 +52,11 @@ public class EiffelRemremCommonControllerUnitTest {
@Mock
RestTemplate restTemplate;

@InjectMocks
ProducerController unit = new ProducerController();
@Spy
GenerateURLTemplate generateURLTemplate;

@InjectMocks
URLTemplate urlT = new URLTemplate();
ProducerController unit = new ProducerController();

@Mock
MsgService service;
Expand Down Expand Up @@ -139,35 +138,24 @@ public void testRestTemplateCallFail() throws Exception {
}

@Test
public void testURLTemplate() throws Exception {

Map<String, String> mapTest = new HashMap<String, String>();
Map<String, String> map = new HashMap<String, String>();
public void testGenerateURLTemplate() throws Exception {

String mp = "eiffeldemantics";
String mp = "eiffelsemantics";
String msgType = "eiffelactivityfinished";
String ud = "userDomain";
String rk = "routingKey";
String tag = "tag";

map = new HashMap<String, String>();
Map<String, String> map = new HashMap<>();
map.put("mp", mp);
map.put("msgType", msgType);
map.put("ud", ud);
map.put("tag", tag);
map.put("rk", rk);

String generateServerHost = "localhost";
String generateServerPort = "8987";
String correctURL = "http://{generateServerHost}:{generateServerPort}/{mp}?msgType={msgType}&ud={ud}&tag={tag}&rk={rk}";
String correctURL = "http://{generateServerHost}:{generateServerPort}/{generateServerAppName}/{mp}?msgType={msgType}";

urlT.generate(mp, msgType, ud, rk, tag, generateServerHost, generateServerPort);
mapTest = urlT.getMap();
Map<String, String> mapTest = generateURLTemplate.getMap(mp, msgType);

assertEquals(generateURLTemplate.getUrl(), correctURL);
assertEquals(mapTest.get("mp"), map.get("mp"));
assertEquals(mapTest.get("msgType"), map.get("msgType"));

assertEquals(urlT.getUrl(), correctURL);
assertEquals(generateURLTemplate.getUrl(), correctURL);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"meta": {
"id": "1afffd13-04ae-4638-97f1-aaeed78a28c7",
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1481628758807,
"tags": ["tag1", "tag2"],
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}],
"meta": {
"type": "eiffelactivityfinished",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}],
"meta": {
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down Expand Up @@ -53,7 +53,7 @@
}],
"meta": {
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down Expand Up @@ -88,7 +88,7 @@
}],
"meta": {
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"meta": {
"id": "9cdd0f68-df85-44b0-88bd-fc4163ac90a1",
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down Expand Up @@ -55,7 +55,7 @@
"meta": {
"id": "9cdd0f68-df85-44b0-88bd-fc4163ac90a2",
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down Expand Up @@ -91,7 +91,7 @@
"meta": {
"id": "9cdd0f68-df85-44b0-88bd-fc4163ac90a3",
"type": "EiffelActivityFinishedEvent",
"version": "1.0.0",
"version": "1.1.0",
"time": 1478780245184,
"tags": ["tag1", "tag2"],
"source": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

public class RemremPublishServiceConstants {

public static final String GENERATE_NO_SERVICE_ERROR = "{\"status_code\": 503, \"result\": \"FAIL\", "
+ "\"message\": \"Message protocol is invalid\"}";

public static final String GENERATE_BAD_REQUEST = "{\"status_code\": 400, \"result\": \"FAIL\", "
+ "\"message\": \"Malformed JSON or incorrect type of event\"}";

public static final String GENERATE_UNAUTHORIZED = "{\"status_code\": 401, \"result\": \"FAIL\", "
+ "\"message\": \"Unauthorized. Please, check if LDAP for REMReM Generate Service is disabled\"}";

public static final String GENERATE_INTERNAL_ERROR = "{\"status_code\": 500, \"result\": \"FAIL\", "
+ "\"message\": \"Internal server error\"}";

public static final String DOCUMENTATION_URL = "http://ericsson.github.io/eiffel-remrem-publish/index.html";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.ericsson.eiffel.remrem.publish.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
* A class for generating URL template of REMReM Generate Service
*
*/
@Component
public class GenerateURLTemplate {

@Value("${generate.server.host}")
private String generateServerHost;

@Value("${generate.server.port}")
private String generateServerPort;

@Value("${generate.server.appName}")
private String generateServerAppName;

public String getUrl() {
return "http://{generateServerHost}:{generateServerPort}/{generateServerAppName}/{mp}?msgType={msgType}";
}

public Map<String, String> getMap(final String mp, final String msgType) {
Map<String, String> map = new HashMap<>();
map.put("mp", mp);
map.put("msgType", msgType);
map.put("generateServerHost", generateServerHost);
map.put("generateServerPort", generateServerPort);
map.put("generateServerAppName", generateServerAppName);

return map;
}

}
Loading

0 comments on commit 4433563

Please sign in to comment.