Implant vid-app-common org.onap.vid.job (main and test)
[vid.git] / vid-app-common / src / test / java / org / onap / vid / job / impl / DeleteOldJobsWorkerTest.java
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.vid.job.command;
+package org.onap.vid.job.impl;
 
-import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.job.JobCommand;
-import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.annotation.Scope;
-import org.springframework.stereotype.Component;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 
+import org.onap.vid.job.JobsBrokerService;
+import org.quartz.JobExecutionException;
+import org.testng.annotations.Test;
 
-@Component
-@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-public class ALaCarteServiceInstantiationCommand extends ServiceInstantiationCommand implements JobCommand {
+public class DeleteOldJobsWorkerTest {
 
-    @Override
-    protected RequestDetailsWrapper<ServiceInstantiationRequestDetails> generateServiceInstantiationRequest() {
-        return asyncInstantiationBL.generateALaCarteServiceInstantiationRequest(
-                getSharedData().getJobUuid(), getRequest(), optimisticUniqueServiceInstanceName, getSharedData().getUserId()
-        );
+    @Test
+    public void whenExecuteInternal_thenCallToDeleteOldFinalJobs() throws JobExecutionException {
+        JobsBrokerService mockBroker = mock(JobsBrokerService.class);
+        long secondsAgo = 42L;
+        DeleteOldJobsWorker underTest = new DeleteOldJobsWorker();
+        underTest.setJobsBrokerService(mockBroker);
+        underTest.setSecondsAgo(secondsAgo);
+        underTest.executeInternal(null);
+        verify(mockBroker).deleteOldFinalJobs(secondsAgo);
     }
+
 }