Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MODTLR-5' into MODTLR-5
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-barannyk committed Jan 11, 2024
2 parents 69f45ff + 41418c4 commit 76e4cb7
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
13 changes: 13 additions & 0 deletions descriptors/ModuleDescriptor-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@
"pathPattern": "/_/tenant"
}
]
},
{
"id": "_timer",
"version": "1.0",
"interfaceType": "system",
"handlers": [
{
"methods": [ "POST" ],
"pathPattern": "/title-level-requests-processing",
"unit": "second",
"delay": "30"
}
]
}
],
"permissionSets" : [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.folio.controller;

import org.folio.service.OpenRequestsProcessingService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;

@RestController
@RequiredArgsConstructor
@Log4j2
public class OpenRequestsProcessingController {

private final OpenRequestsProcessingService openRequestsProcessingService;

@PostMapping(value = "/title-level-requests-processing")
public void processOpenRequests() {
openRequestsProcessingService.processOpenRequests();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.folio.service;

public interface OpenRequestsProcessingService {
void processOpenRequests();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.folio.service.impl;

import org.folio.service.OpenRequestsProcessingService;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;

@Service
@RequiredArgsConstructor
@Log4j2
public class OpenRequestsProcessingServiceImpl implements OpenRequestsProcessingService {

@Override
public void processOpenRequests() {
log.info("processOpenRequests:: start");
}

}
20 changes: 20 additions & 0 deletions src/test/java/org/folio/api/OpenRequestsProcessingApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.folio.api;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;

class OpenRequestsProcessingApiTest extends BaseIT {
private static final String PROCESS_OPEN_REQUESTS_URL = "/title-level-requests-processing";

@Test
void getByIdNotFound() throws Exception {
mockMvc.perform(
post(PROCESS_OPEN_REQUESTS_URL)
.headers(defaultHeaders())
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.folio.controller;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import org.folio.service.OpenRequestsProcessingService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class OpenRequestsProcessingControllerTest {

@Mock
private OpenRequestsProcessingService service;

@InjectMocks
private OpenRequestsProcessingController controller;

@Test
void openRequestsProcessingServiceCalledFromController() {
controller.processOpenRequests();
verify(service, times(1)).processOpenRequests();
}

}

0 comments on commit 76e4cb7

Please sign in to comment.