From 3056fc5e1d4a9c018188561df6c946c4f54d5736 Mon Sep 17 00:00:00 2001 From: Andrey Ivanov Date: Thu, 1 Jun 2017 11:09:18 +0300 Subject: [PATCH] Unit test for JobExecutorDelegate added --- .../job/JobExecutorDelegateTest.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/test/java/com/epam/ta/reportportal/job/JobExecutorDelegateTest.java diff --git a/src/test/java/com/epam/ta/reportportal/job/JobExecutorDelegateTest.java b/src/test/java/com/epam/ta/reportportal/job/JobExecutorDelegateTest.java new file mode 100644 index 0000000000..6fe8d542b4 --- /dev/null +++ b/src/test/java/com/epam/ta/reportportal/job/JobExecutorDelegateTest.java @@ -0,0 +1,58 @@ +/* + * Copyright 2016 EPAM Systems + * + * + * This file is part of EPAM Report Portal. + * https://github.com/reportportal/service-api + * + * Report Portal is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Report Portal is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Report Portal. If not, see . + */ + +package com.epam.ta.reportportal.job; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.TaskScheduler; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.mockito.Mockito.*; + +/** + * Created by Andrey_Ivanov1 on 31-May-17. + */ + +@RunWith(SpringJUnit4ClassRunner.class) +public class JobExecutorDelegateTest { + + @InjectMocks + private JobExecutorDelegate jobExecutorDelegate = new JobExecutorDelegate(); + @Mock + private SelfCancalableJob selfCancalableJob; + @Mock + private TaskScheduler taskScheduler; + + @Test + public void submitJobTest() { + jobExecutorDelegate.submitJob(selfCancalableJob); + verify(taskScheduler, times(1)) + .schedule(selfCancalableJob, selfCancalableJob); + } + +} \ No newline at end of file