@@ -75,6 +75,21 @@ void testCreate() throws Exception {
75
75
assertThat (createdConfig .getCustomColumns ()).allMatch (column -> column .getId () != null );
76
76
}
77
77
78
+ @ Test
79
+ void testCreateWithInvalidData () throws Exception {
80
+ SpreadsheetConfigDto invalidConfig = SpreadsheetConfigDto .builder ()
81
+ .sheetType (null ) // SheetType is required
82
+ .customColumns (createCustomColumns ())
83
+ .build ();
84
+
85
+ String invalidConfigJson = mapper .writeValueAsString (invalidConfig );
86
+
87
+ mockMvc .perform (post (URI_SPREADSHEET_CONFIG_BASE )
88
+ .content (invalidConfigJson )
89
+ .contentType (MediaType .APPLICATION_JSON ))
90
+ .andExpect (status ().isBadRequest ());
91
+ }
92
+
78
93
@ Test
79
94
void testRead () throws Exception {
80
95
SpreadsheetConfigDto configToRead = SpreadsheetConfigDto .builder ()
@@ -94,6 +109,37 @@ void testRead() throws Exception {
94
109
assertThat (receivedConfig .getCustomColumns ()).allMatch (column -> column .getId () != null );
95
110
}
96
111
112
+ @ Test
113
+ void testReadNonExistent () throws Exception {
114
+ UUID nonExistentUuid = UUID .randomUUID ();
115
+
116
+ mockMvc .perform (get (URI_SPREADSHEET_CONFIG_GET_PUT + nonExistentUuid ))
117
+ .andExpect (status ().isNotFound ());
118
+ }
119
+
120
+ @ Test
121
+ void testUpdateWithInvalidData () throws Exception {
122
+ SpreadsheetConfigDto configToUpdate = SpreadsheetConfigDto .builder ()
123
+ .sheetType (SheetType .BATTERIES )
124
+ .customColumns (createCustomColumns ())
125
+ .build ();
126
+
127
+ UUID configUuid = saveAndReturnId (configToUpdate );
128
+
129
+ SpreadsheetConfigDto invalidUpdate = SpreadsheetConfigDto .builder ()
130
+ .id (configUuid )
131
+ .sheetType (null ) // SheetType is required
132
+ .customColumns (createUpdatedCustomColumns ())
133
+ .build ();
134
+
135
+ String invalidUpdateJson = mapper .writeValueAsString (invalidUpdate );
136
+
137
+ mockMvc .perform (put (URI_SPREADSHEET_CONFIG_GET_PUT + configUuid )
138
+ .content (invalidUpdateJson )
139
+ .contentType (MediaType .APPLICATION_JSON ))
140
+ .andExpect (status ().isBadRequest ());
141
+ }
142
+
97
143
@ Test
98
144
void testUpdate () throws Exception {
99
145
SpreadsheetConfigDto configToUpdate = SpreadsheetConfigDto .builder ()
@@ -141,6 +187,14 @@ void testDelete() throws Exception {
141
187
assertThat (storedConfigs ).isEmpty ();
142
188
}
143
189
190
+ @ Test
191
+ void testDeleteNonExistent () throws Exception {
192
+ UUID nonExistentUuid = UUID .randomUUID ();
193
+
194
+ mockMvc .perform (delete (URI_SPREADSHEET_CONFIG_GET_PUT + nonExistentUuid ))
195
+ .andExpect (status ().isNotFound ());
196
+ }
197
+
144
198
@ Test
145
199
void testGetAll () throws Exception {
146
200
SpreadsheetConfigDto config1 = SpreadsheetConfigDto .builder ()
@@ -182,6 +236,15 @@ void testDuplicate() throws Exception {
182
236
assertThat (duplicatedConfig .getId ()).isNotEqualTo (configUuid );
183
237
}
184
238
239
+ @ Test
240
+ void testDuplicateNonExistent () throws Exception {
241
+ UUID nonExistentUuid = UUID .randomUUID ();
242
+
243
+ mockMvc .perform (post (URI_SPREADSHEET_CONFIG_BASE + "/duplicate" )
244
+ .queryParam ("duplicateFrom" , nonExistentUuid .toString ()))
245
+ .andExpect (status ().isNotFound ());
246
+ }
247
+
185
248
private List <CustomColumnDto > createCustomColumns () {
186
249
return Arrays .asList (
187
250
new CustomColumnDto (null , "cust_a" , "cust_b + cust_c" ),
0 commit comments