Skip to content

Commit 1345db0

Browse files
committed
Ut's update
1 parent 875e40c commit 1345db0

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

app/single-tenant/personal-space/demoapp/srv/src/test/java/customer/demoapp/handlers/CatalogServiceNonDraftReadIT.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.springframework.beans.factory.annotation.Autowired;
99
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
1010
import org.springframework.boot.test.context.SpringBootTest;
11+
import org.springframework.security.test.context.support.WithMockUser;
1112
import org.springframework.test.web.servlet.MockMvc;
1213

1314
/**
@@ -43,6 +44,7 @@ class CatalogServiceNonDraftReadIT {
4344
* populateUploadableFlags tries to SELECT IsActiveEntity from a non-draft attachment entity.
4445
*/
4546
@Test
47+
@WithMockUser
4648
void nonDraftReadOfBooksWithAttachmentsMustReturn200() throws Exception {
4749
mockMvc.perform(get(BOOKS_URI))
4850
.andExpect(status().isOk())
@@ -57,6 +59,7 @@ void nonDraftReadOfBooksWithAttachmentsMustReturn200() throws Exception {
5759
* processed without error.
5860
*/
5961
@Test
62+
@WithMockUser
6063
void nonDraftReadWithTopOneStillReturns200() throws Exception {
6164
mockMvc.perform(get(BOOKS_URI + "?$top=1"))
6265
.andExpect(status().isOk())
@@ -70,6 +73,7 @@ void nonDraftReadWithTopOneStillReturns200() throws Exception {
7073
* populateUploadableFlags fully, hitting getAttachmentsForUPID once per facet.
7174
*/
7275
@Test
76+
@WithMockUser
7377
void nonDraftReadWithFilterStillReturns200() throws Exception {
7478
mockMvc.perform(get(BOOKS_URI + "?$filter=stock gt 0"))
7579
.andExpect(status().isOk())

sdm/src/test/java/unit/com/sap/cds/sdm/handler/applicationservice/SDMReadAttachmentsHandlerPopulateUploadableFlagsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ void testPopulateUploadableFlags_path1_isDraft_draftEntityFound() {
228228
when(target.getQualifiedName()).thenReturn("sap.capire.Books");
229229
when(target.compositions()).thenAnswer(inv -> Stream.of(buildComposition("attachments", "3")));
230230
when(target.elements()).thenAnswer(inv -> Stream.of(buildKeyElement("ID")));
231+
// entity has draft support — IsActiveEntity element is present
232+
when(target.findElement("IsActiveEntity")).thenReturn(Optional.of(mock(CdsElement.class)));
231233
// isDraft=true because IsActiveEntity=false
232234
when(model.findEntity("sap.capire.Books.attachments_drafts"))
233235
.thenReturn(Optional.of(draftAttachmentEntity));
@@ -262,6 +264,8 @@ void testPopulateUploadableFlags_path1_isDraft_draftEntityNotFound_fallbackActiv
262264
when(target.getQualifiedName()).thenReturn("sap.capire.Books");
263265
when(target.compositions()).thenAnswer(inv -> Stream.of(buildComposition("attachments", "2")));
264266
when(target.elements()).thenAnswer(inv -> Stream.of(buildKeyElement("ID")));
267+
// entity has draft support — IsActiveEntity element is present
268+
when(target.findElement("IsActiveEntity")).thenReturn(Optional.of(mock(CdsElement.class)));
265269
when(model.findEntity("sap.capire.Books.attachments_drafts")).thenReturn(Optional.empty());
266270
when(model.findEntity("sap.capire.Books.attachments"))
267271
.thenReturn(Optional.of(activeAttachmentEntity));

0 commit comments

Comments
 (0)