Skip to content

Commit

Permalink
fix: add changes after review comment, remove unnecessary check
Browse files Browse the repository at this point in the history
  • Loading branch information
m-rudyk committed Feb 14, 2024
1 parent 04b4d6b commit 345fda7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions src/main/java/com/lpvs/service/LPVSQueueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,9 @@ public BlockingDeque<LPVSQueue> getQueue() {
public void checkForQueue() throws InterruptedException {
log.debug("Checking for previous queue");
List<LPVSQueue> webhookConfigList = queueRepository.getQueueList();
if (webhookConfigList.size() > 0) {
LPVSQueue webhookConfig = getLatestScan(webhookConfigList);
webhookConfig.setAttempts(webhookConfig.getAttempts() + 1);
queueRepository.save(webhookConfig);
}
for (LPVSQueue webhook : webhookConfigList) {
log.info("PROCESSING WebHook id = " + webhook.getId());
if (webhook.getAttempts() > maxAttempts) {
if (webhook.getAttempts() < maxAttempts) {
LPVSPullRequest pullRequest = new LPVSPullRequest();
pullRequest.setPullRequestUrl(webhook.getPullRequestUrl());
pullRequest.setUser(webhook.getUserId());
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/com/lpvs/service/LPVSQueueServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,23 @@ void setUp() {
@Test
public void testCheckForQueue() {
LPVSQueue webhookConfig = new LPVSQueue();
webhookConfig.setAttempts(0);
webhookConfig.setAttempts(100);
webhookConfig.setDate(new Date());
when(mocked_queueRepository.getQueueList()).thenReturn(List.of(webhookConfig));
assertDoesNotThrow(() -> queueService.checkForQueue());
verify(mocked_queueRepository).save(webhookConfig);
}

@Test
public void testCheckForQueue__Alternative() {
LPVSQueue webhookConfig = new LPVSQueue();
webhookConfig.setAttempts(100);
webhookConfig.setAttempts(0);
webhookConfig.setDate(new Date());
webhookConfig.setUserId("id");
webhookConfig.setRepositoryUrl("https://github.com/Samsung/LPVS");
when(mocked_queueRepository.getQueueList()).thenReturn(List.of(webhookConfig));
when(mocked_lpvsPullRequestRepository.saveAndFlush(Mockito.any(LPVSPullRequest.class)))
.thenAnswer(i -> i.getArguments()[0]);
assertDoesNotThrow(() -> queueService.checkForQueue());
verify(mocked_queueRepository).save(webhookConfig);
}

@Test
Expand Down

0 comments on commit 345fda7

Please sign in to comment.