File tree Expand file tree Collapse file tree 4 files changed +57
-6
lines changed
main/java/com/ericsson/eiffel/remrem/semantics/events
test/java/com/ericsson/eiffel/remrem/semantics Expand file tree Collapse file tree 4 files changed +57
-6
lines changed Original file line number Diff line number Diff line change 11.idea /*
22build
33.gradle /*
4+ /bin /
Original file line number Diff line number Diff line change @@ -22,15 +22,22 @@ allprojects {
2222
2323jar {
2424 baseName = ' eiffel-remrem-semantics'
25- version = ' 0.1.3'
25+ // If this version is updated please update it in Event.java
26+ // com.ericsson.eiffel.remrem.semantics.events
27+ version = ' 0.1.4'
28+ manifest {
29+ attributes(' Semantics-Version' : version)
30+ }
2631}
2732
2833shadowJar {
2934 baseName = ' eiffel-remrem-semantics'
30- version = ' 0.1.3 '
35+ version = ' 0.1.4 '
3136 classifier = ' '
3237}
3338
39+ apply plugin : ' eclipse'
40+
3441task wrapper (type : Wrapper ) {
3542 gradleVersion = ' 2.12'
3643 distributionUrl = " https://services.gradle.org/distributions/gradle-$gradleVersion -all.zip"
@@ -59,11 +66,12 @@ install.dependsOn shadowJar
5966// }
6067
6168dependencies {
62- compile ' org.springframework:spring-context:4.2.5 .RELEASE'
69+ compile ' org.springframework:spring-context:4.3.3 .RELEASE'
6370 compile ' com.github.Ericsson:eiffel-remrem-shared:0.1.4'
6471 compile ' com.github.fge:json-schema-validator:2.2.6'
6572 compile ' org.slf4j:slf4j-api:1.7.18'
6673 compile group : ' com.google.code.gson' , name : ' gson' , version : ' 1.7.2'
6774 compile group : ' org.projectlombok' , name : ' lombok' , version : ' 1.16.8'
75+ compile ' org.mockito:mockito-core:2.1.0'
6876 testCompile ' junit:junit:4.12'
6977}
Original file line number Diff line number Diff line change 55
66import com .ericsson .eiffel .remrem .semantics .models .Meta ;
77
8+ import java .io .IOException ;
9+ import java .io .InputStream ;
810import java .util .UUID ;
11+ import java .util .jar .Attributes ;
12+ import java .util .jar .Manifest ;
913
1014
1115public abstract class Event {
1216 public Meta meta ;
13- public static String version = "0.1.0 " ;
17+ public static String version = "0.1.4 " ;
1418
1519 public void generateMeta (String msgType , JsonObject msgNodes ) {
1620 meta = new Gson ().fromJson (msgNodes .get ("meta" ), Meta .class );
1721 meta .setType (msgType );
1822 meta .setTime (System .currentTimeMillis ());
23+ // TO DO unit tests are not working
24+ // String version = getCurrentVersion();
1925 meta .setVersion (version );
2026 meta .setId (UUID .randomUUID ().toString ());
2127 }
2228
23- }
24-
29+ public String getCurrentVersion () {
30+ InputStream manifestStream = Thread .currentThread ()
31+ .getContextClassLoader ()
32+ .getResourceAsStream ("/META-INF/MANIFEST.MF" );
33+ try {
34+ Manifest manifest = new Manifest (manifestStream );
35+ Attributes attributes = manifest .getMainAttributes ();
36+ return attributes .getValue ("Semantics-Version" );
37+ }
38+ catch (IOException ex ) {
39+
40+ }
41+
42+ return null ;
43+ }
44+ }
Original file line number Diff line number Diff line change 11package com .ericsson .eiffel .remrem .semantics ;
22
3+ import com .ericsson .eiffel .remrem .semantics .events .Event ;
34import com .google .gson .JsonObject ;
45import com .google .gson .JsonParser ;
56import org .junit .Assert ;
7+ import org .junit .Before ;
68import org .junit .Test ;
9+ import org .mockito .InjectMocks ;
10+ import org .mockito .Mock ;
11+ import org .mockito .Mockito ;
12+ import static org .mockito .Mockito .mock ;
13+ import static org .mockito .Mockito .when ;
14+ import org .mockito .MockitoAnnotations ;
715
816import java .io .File ;
917import java .io .FileNotFoundException ;
1018import java .io .FileReader ;
19+ import java .util .jar .Attributes ;
20+ import java .util .jar .Manifest ;
1121
1222public class ServiceTest {
1323
1424 private String ACTIVITY_FINISHED = "eiffelactivityfinished" ;
1525 private String ARTIFACT_PUBLISHED = "eiffelartifactpublished" ;
1626
1727 JsonParser parser = new JsonParser ();
28+
29+ @ InjectMocks
1830 SemanticsService service = new SemanticsService ();
1931
32+
33+ private Event event ;
34+
35+ @ Before
36+ public void setUp () throws Exception {
37+ MockitoAnnotations .initMocks (this );
38+ event = mock (Event .class );
39+ when (event .getCurrentVersion ()).thenReturn ("0.1.0" );
40+ }
41+
2042 private void testGenerateMsg (String msgType , String fileName ) {
2143
2244 try {
You can’t perform that action at this time.
0 commit comments