Skip to content

Commit

Permalink
Added functionality to list endpoint versions (#43)
Browse files Browse the repository at this point in the history
* update version of semantics and small dependency conflicts for integration tests

* some updates

* update gradle and semantic version

* Unit test cli

Change-Id: I38c1122b5914522a87250eeac4a637796e19d8bf

* automatically fetch semantics version and indentation fix

Change-Id: Icba3859a3c6c60cfb1ec0d62dd3f1e8eb6be7e65

* Unit test cli

Change-Id: I38c1122b5914522a87250eeac4a637796e19d8bf

* new tests and help flag error fix

Change-Id: I0c76b77a92a39629a672d1c1b59b0c1556b32c09

* update integration tests

Change-Id: I534ffda3d68f6e66270a7486ae58b643208401e8

* update version and changelog

Change-Id: If01cc1cecd05fa0489e518edffcf36ac141c734d

* add service for listing versions of used message protocols

Change-Id: I61a6d3d081e6ba9c81960c6fc23a764cf4a7a30e

* Added --list-versions CLI option to list the endpoint versions

* Using underscore for --list_versions CLI optoion format, and renamed the endpoint request to /versions

* Added eiffel-remrem-protocol-interface

* Added functiolaity to list endpoint versions
  • Loading branch information
afshinhm-ericsson authored Dec 5, 2016
1 parent ba1d5a1 commit 0ce0702
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.7.0
- Added functiolaity to list endpoint versions

## 0.6.3
- Removed unused dependency.

Expand Down
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'war'

war {
baseName = 'remrem-generate'
version = '0.6.3'
version = '0.7.0'
}


Expand Down Expand Up @@ -139,8 +139,9 @@ dependencies {
testCompile("org.springframework.boot:spring-boot-starter-tomcat")

//Injectable Message Library and its Implementation
compile 'com.github.Ericsson:eiffel-remrem-shared:0.1.4'
compile ('com.github.Ericsson:eiffel-remrem-semantics:0.1.7')
compile ('com.github.Ericsson:eiffel-remrem-shared:0.3.0')
compile ('com.github.Ericsson:eiffel-remrem-semantics:0.1.9')
compile ('com.github.Ericsson:eiffel-remrem-protocol-interface:0.0.1')

//commons CLI
compile 'commons-cli:commons-cli:1.3.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static String getMessagingVersion() {
if (is != null) {
Manifest manifest = new Manifest(is);
Attributes mainAttribs = manifest.getMainAttributes();
String version = mainAttribs.getValue("Semantics-Version");
String version = mainAttribs.getValue("semanticsVersion");
if(version != null) {
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;
import org.springframework.boot.CommandLineRunner;

import com.ericsson.eiffel.remrem.generate.config.PropertiesConfig;
import com.ericsson.eiffel.remrem.protocol.MsgService;
import com.ericsson.eiffel.remrem.semantics.SemanticsService;
import com.ericsson.eiffel.remrem.shared.MsgService;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ericsson.eiffel.remrem.generate.cli;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
Expand All @@ -14,6 +14,7 @@

import com.ericsson.eiffel.remrem.generate.helper.RemremJarHelper;
import com.ericsson.eiffel.remrem.generate.config.PropertiesConfig;
import com.ericsson.eiffel.remrem.shared.VersionService;


public class CLIOptions {
Expand Down Expand Up @@ -66,6 +67,7 @@ public static Options createCLIOptions() {
contentGroup.addOption(new Option("json", "json_content", true, "json content"));
options.addOptionGroup(contentGroup);

options.addOption("lv", "list_versions", false, "list the version and all loaded protocols");
return options;
}

Expand Down Expand Up @@ -113,11 +115,36 @@ public static void afterParseChecks() throws MissingOptionException{
if (commandLine.hasOption("h")) {
System.out.println("You passed help flag.");
help(0);
} else {
} else if (commandLine.hasOption("lv")) {
printVersions();
} else {
checkRequiredOptions();
}
}


/**
* Lists the version and all loaded protocols
*/
private static void printVersions() {
Map versions = VersionService.getMessagingVersions();
Map<String, String> endpointVersions = (Map<String, String>) versions.get("endpointVersions");
Map<String, String> serviceVersion = (Map<String, String>) versions.get("serviceVersion");

if(serviceVersion != null) {
System.out.print("REMREM Generate version ");
for (String version: serviceVersion.values()) {
System.out.println(version);
}
}
if(endpointVersions != null) {
System.out.println("Available endpoints");
for (Map.Entry<String, String> entry : endpointVersions.entrySet()) {
System.out.println(entry);
}
}
exit(0);
}

public static void checkRequiredOptions() throws MissingOptionException {
OptionGroup[] groups = {typeGroup, contentGroup};
for(OptionGroup group : groups) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.ericsson.eiffel.remrem.generate.controller;

import com.ericsson.eiffel.remrem.protocol.MsgService;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import com.ericsson.eiffel.remrem.shared.MsgService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Profile;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.ericsson.eiffel.remrem.generate.controller;

import com.ericsson.eiffel.remrem.protocol.MsgService;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import com.ericsson.eiffel.remrem.shared.MsgService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.ericsson.eiffel.remrem.generate.controller;

import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.ericsson.eiffel.remrem.shared.VersionService;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;

@RestController @RequestMapping("/versions")
public class VersionsController {

JsonParser parser = new JsonParser();

@RequestMapping(value = "", method = RequestMethod.POST)
public JsonElement getVersions() {
Map versions = VersionService.getMessagingVersions();
return parser.parse(versions.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.springframework.test.context.junit4.SpringRunner;

import com.ericsson.eiffel.remrem.generate.config.PropertiesConfig;
import com.ericsson.eiffel.remrem.shared.MsgService;
import com.ericsson.eiffel.remrem.protocol.MsgService;

@RunWith(SpringRunner.class)
public class CliUnitTests {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.JsonObject;

import com.ericsson.eiffel.remrem.generate.controller.Eiffel3Controller;
import com.ericsson.eiffel.remrem.shared.MsgService;
import com.ericsson.eiffel.remrem.protocol.MsgService;

import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.JsonObject;

import com.ericsson.eiffel.remrem.generate.controller.EiffelSemanticsController;
import com.ericsson.eiffel.remrem.shared.MsgService;
import com.ericsson.eiffel.remrem.protocol.MsgService;

import org.junit.Before;
import org.junit.Test;
Expand Down

0 comments on commit 0ce0702

Please sign in to comment.