Skip to content

Commit d7a968a

Browse files
committed
updated test and handler files
1 parent c3a9383 commit d7a968a

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

srv/src/main/java/com/sap/cap/incident_management/handler/ProcessorServiceHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,5 @@ public void onUpdate(Incidents incident) {
5656
}
5757

5858

59-
60-
6159

6260
}

srv/src/test/java/com/sap/cap/incident_management/IncidentsODataTests.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class IncidentsODataTests {
2525
@Autowired
2626
private MockMvc mockMvc;
2727

28+
/**
29+
* Test GET Api for Incidents
30+
* @throws Exception
31+
*/
2832
@Test
2933
@WithMockUser(username = "alice")
3034
void incidentReturned() throws Exception {
@@ -33,6 +37,11 @@ void incidentReturned() throws Exception {
3337
.andExpect(jsonPath("$.value", hasSize(4)));
3438

3539
}
40+
41+
/**
42+
* Test GET Api for Customers
43+
* @throws Exception
44+
*/
3645
@Test
3746
@WithMockUser(username = "alice")
3847
void customertReturned() throws Exception {
@@ -42,6 +51,11 @@ void customertReturned() throws Exception {
4251

4352
}
4453

54+
/**
55+
* Test to ensure there is an Incident created by each Customer.
56+
* @throws Exception
57+
*/
58+
4559
@Test
4660
@WithMockUser(username = "alice")
4761
void expandEntityEndpoint() throws Exception {
@@ -50,6 +64,12 @@ void expandEntityEndpoint() throws Exception {
5064
.andExpect(jsonPath("$.value[0].incidents[0]").isNotEmpty());
5165

5266
}
67+
68+
/**
69+
* Test to create an Incident.
70+
* Test custom handler ensuring High Urgency For Incidents With "Urgent" in Title
71+
* @throws Exception
72+
*/
5373
@Test
5474
@WithMockUser(username = "alice")
5575
void createIncident() throws Exception {
@@ -66,6 +86,12 @@ void createIncident() throws Exception {
6686
.andExpect(jsonPath("$.urgency_code").value("H"));
6787
}
6888

89+
/**
90+
* Test for creating an Incident
91+
* Test for closing the Incident
92+
* Test for custom handler ensuing prevent users from modifying a closed Incident
93+
*/
94+
6995
@Test
7096
@WithMockUser(username = "alice")
7197
void updateIncident() throws Exception {
@@ -85,7 +111,9 @@ void updateIncident() throws Exception {
85111
String createResponseContent = createResult.getResponse().getContentAsString();
86112
String ID = JsonPath.read(createResponseContent, "$.ID");
87113
System.out.println("Incident ID : " + ID);
88-
114+
/**
115+
* Closing an open Incident
116+
*/
89117
MvcResult updateResult= mockMvc.perform(MockMvcRequestBuilders.patch("/odata/v4/ProcessorService/Incidents(ID="+ID+",IsActiveEntity=true)")
90118
.content(incidentUpdateJson)
91119
.contentType("application/json")
@@ -99,7 +127,9 @@ void updateIncident() throws Exception {
99127
String statusCode = JsonPath.read(updateResponseContent, "$.status_code");
100128
System.out.println("status code : " + statusCode);
101129

102-
130+
/**
131+
* Updating a Closed Incident will throw an error with error message "Can't modify a closed incident"
132+
*/
103133
mockMvc.perform(MockMvcRequestBuilders.patch("/odata/v4/ProcessorService/Incidents(ID="+ID+",IsActiveEntity=true)")
104134
.content(closedIncidentUpdateJson)
105135
.contentType("application/json")

0 commit comments

Comments
 (0)