File tree 4 files changed +57
-6
lines changed
main/java/com/ericsson/eiffel/remrem/semantics/events
test/java/com/ericsson/eiffel/remrem/semantics
4 files changed +57
-6
lines changed Original file line number Diff line number Diff line change 1
1
.idea /*
2
2
build
3
3
.gradle /*
4
+ /bin /
Original file line number Diff line number Diff line change @@ -22,15 +22,22 @@ allprojects {
22
22
23
23
jar {
24
24
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
+ }
26
31
}
27
32
28
33
shadowJar {
29
34
baseName = ' eiffel-remrem-semantics'
30
- version = ' 0.1.3 '
35
+ version = ' 0.1.4 '
31
36
classifier = ' '
32
37
}
33
38
39
+ apply plugin : ' eclipse'
40
+
34
41
task wrapper (type : Wrapper ) {
35
42
gradleVersion = ' 2.12'
36
43
distributionUrl = " https://services.gradle.org/distributions/gradle-$gradleVersion -all.zip"
@@ -59,11 +66,12 @@ install.dependsOn shadowJar
59
66
// }
60
67
61
68
dependencies {
62
- compile ' org.springframework:spring-context:4.2.5 .RELEASE'
69
+ compile ' org.springframework:spring-context:4.3.3 .RELEASE'
63
70
compile ' com.github.Ericsson:eiffel-remrem-shared:0.1.4'
64
71
compile ' com.github.fge:json-schema-validator:2.2.6'
65
72
compile ' org.slf4j:slf4j-api:1.7.18'
66
73
compile group : ' com.google.code.gson' , name : ' gson' , version : ' 1.7.2'
67
74
compile group : ' org.projectlombok' , name : ' lombok' , version : ' 1.16.8'
75
+ compile ' org.mockito:mockito-core:2.1.0'
68
76
testCompile ' junit:junit:4.12'
69
77
}
Original file line number Diff line number Diff line change 5
5
6
6
import com .ericsson .eiffel .remrem .semantics .models .Meta ;
7
7
8
+ import java .io .IOException ;
9
+ import java .io .InputStream ;
8
10
import java .util .UUID ;
11
+ import java .util .jar .Attributes ;
12
+ import java .util .jar .Manifest ;
9
13
10
14
11
15
public abstract class Event {
12
16
public Meta meta ;
13
- public static String version = "0.1.0 " ;
17
+ public static String version = "0.1.4 " ;
14
18
15
19
public void generateMeta (String msgType , JsonObject msgNodes ) {
16
20
meta = new Gson ().fromJson (msgNodes .get ("meta" ), Meta .class );
17
21
meta .setType (msgType );
18
22
meta .setTime (System .currentTimeMillis ());
23
+ // TO DO unit tests are not working
24
+ // String version = getCurrentVersion();
19
25
meta .setVersion (version );
20
26
meta .setId (UUID .randomUUID ().toString ());
21
27
}
22
28
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 1
1
package com .ericsson .eiffel .remrem .semantics ;
2
2
3
+ import com .ericsson .eiffel .remrem .semantics .events .Event ;
3
4
import com .google .gson .JsonObject ;
4
5
import com .google .gson .JsonParser ;
5
6
import org .junit .Assert ;
7
+ import org .junit .Before ;
6
8
import 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 ;
7
15
8
16
import java .io .File ;
9
17
import java .io .FileNotFoundException ;
10
18
import java .io .FileReader ;
19
+ import java .util .jar .Attributes ;
20
+ import java .util .jar .Manifest ;
11
21
12
22
public class ServiceTest {
13
23
14
24
private String ACTIVITY_FINISHED = "eiffelactivityfinished" ;
15
25
private String ARTIFACT_PUBLISHED = "eiffelartifactpublished" ;
16
26
17
27
JsonParser parser = new JsonParser ();
28
+
29
+ @ InjectMocks
18
30
SemanticsService service = new SemanticsService ();
19
31
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
+
20
42
private void testGenerateMsg (String msgType , String fileName ) {
21
43
22
44
try {
You can’t perform that action at this time.
0 commit comments