Skip to content

Commit 618d36c

Browse files
ned29emichaf
authored andcommitted
ADD: subscription template (#66)
* ADD: subscription template * Add RAML implementation
1 parent c72d2ba commit 618d36c

File tree

6 files changed

+162
-1
lines changed

6 files changed

+162
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.ericsson.ei.controller;
2+
3+
import io.swagger.annotations.Api;
4+
import io.swagger.annotations.ApiOperation;
5+
import org.apache.commons.io.IOUtils;
6+
import org.slf4j.Logger;
7+
import org.slf4j.LoggerFactory;
8+
import org.springframework.http.HttpHeaders;
9+
import org.springframework.http.HttpStatus;
10+
import org.springframework.http.ResponseEntity;
11+
import org.springframework.stereotype.Component;
12+
import org.springframework.web.bind.annotation.CrossOrigin;
13+
14+
import java.io.IOException;
15+
import java.io.InputStream;
16+
17+
@Component
18+
@CrossOrigin
19+
@Api(value = "Get template", description = "REST end-points for template subscription")
20+
public class SubscriptionTemplateControllerImpl implements SubscriptiontemplateController {
21+
22+
private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(SubscriptionTemplateControllerImpl.class);
23+
24+
@Override
25+
@CrossOrigin
26+
@ApiOperation(value = "")
27+
public ResponseEntity<?> getDownloadSubscriptiontemplate() {
28+
try {
29+
InputStream is = getClass().getResourceAsStream("/subscriptionsTemplate.json");
30+
return new ResponseEntity<>(IOUtils.toByteArray(is), new HttpHeaders(), HttpStatus.OK);
31+
} catch (IOException e) {
32+
LOGGER.error("Error " + e.getMessage());
33+
return new ResponseEntity<>("File not found", HttpStatus.OK);
34+
}
35+
}
36+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
package com.ericsson.ei.controller;
3+
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RequestMethod;
7+
import org.springframework.web.bind.annotation.RestController;
8+
9+
10+
/**
11+
* No description
12+
* (Generated with springmvc-raml-parser v.0.10.11)
13+
*
14+
*/
15+
@RestController
16+
@RequestMapping(value = "/download/subscriptiontemplate", produces = "application/json")
17+
public interface SubscriptiontemplateController {
18+
19+
20+
/**
21+
* Subscription template
22+
*
23+
*/
24+
@RequestMapping(value = "", method = RequestMethod.GET)
25+
public ResponseEntity<?> getDownloadSubscriptiontemplate();
26+
27+
}

src/main/resources/public/raml/eiffel-intelligence.raml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@
2828
baseUri: /
2929
/subscriptions: !include subscription.raml
3030
/query: !include queryservice.raml
31-
/jmespathrule: !include jmespath.raml
31+
/jmespathrule: !include jmespath.raml
32+
/download: !include template.raml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/subscriptiontemplate:
2+
get:
3+
description: Subscription template
4+
responses:
5+
200:
6+
body:
7+
application/json:
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[{
2+
"notificationMessage" : "sample@ericsson.com",
3+
"notificationMeta" : "http://127.0.0.1:3000/ei/test_subscription_rest",
4+
"notificationType" : "REST_POST",
5+
"repeat" : false,
6+
"requirements" : [
7+
{
8+
"conditions" : [
9+
{
10+
"jmespath" : "gav.groupId=='com.mycompany.myproduct'"
11+
},
12+
{
13+
"jmespath" : "testCaseExecutions[?testCase.conclusion == 'SUCCESSFUL' && testCase.id=='TC5']"
14+
}
15+
]
16+
},
17+
{
18+
"conditions" : [
19+
{
20+
"jmespath" : "gav.groupId=='com.mycompany.myproduct'"
21+
},
22+
{
23+
"jmespath" : "testCaseExecutions[?testCaseStartedEventId == '13af4a14-f951-4346-a1ba-624c79f10e98']"
24+
}
25+
]
26+
}
27+
],
28+
"subscriptionName" : "Subscription_Test"
29+
},
30+
{
31+
"notificationMessage" : "sample2@ericsson.com",
32+
"notificationMeta" : "http://127.0.0.1:3000/ei/test_subscription_rest",
33+
"notificationType" : "REST_POST",
34+
"repeat" : false,
35+
"requirements" : [
36+
{
37+
"conditions" : [
38+
{
39+
"jmespath" : "gav.groupId=='com.mycompany.myproduct'"
40+
},
41+
{
42+
"jmespath" : "testCaseExecutions[?testCase.conclusion == 'SUCCESSFUL' && testCase.id=='TC5']"
43+
}
44+
]
45+
},
46+
{
47+
"conditions" : [
48+
{
49+
"jmespath" : "gav.groupId=='com.mycompany.myproduct'"
50+
},
51+
{
52+
"jmespath" : "testCaseExecutions[?testCaseStartedEventId == '13af4a14-f951-4346-a1ba-624c79f10e98']"
53+
}
54+
]
55+
}
56+
],
57+
"subscriptionName" : "Subscription_Test_Modify"
58+
}]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.ericsson.ei.controller;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
7+
import org.springframework.boot.test.mock.mockito.MockBean;
8+
import org.springframework.http.MediaType;
9+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
10+
import org.springframework.test.web.servlet.MockMvc;
11+
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
12+
13+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
14+
15+
@RunWith(SpringJUnit4ClassRunner.class)
16+
@WebMvcTest(value = SubscriptiontemplateController.class, secure = false)
17+
public class TestSubscriptionTemplateControllerImpl {
18+
19+
@Autowired
20+
private MockMvc mockMvc;
21+
22+
@MockBean
23+
private SubscriptiontemplateController subscriptiontemplateController;
24+
25+
@Test
26+
public void testResponseStatus() throws Exception {
27+
mockMvc.perform(MockMvcRequestBuilders.get("/download/subscriptiontemplate")
28+
.accept(MediaType.APPLICATION_JSON_VALUE))
29+
.andExpect(status().isOk())
30+
.andReturn();
31+
}
32+
}

0 commit comments

Comments
 (0)