Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package it.inaf.oats.vospace.persistence;
import javax.sql.DataSource;
import net.ivoa.xml.uws.v1.ExecutionPhase;
import net.ivoa.xml.uws.v1.JobSummary;
import net.ivoa.xml.vospace.v2.ContainerNode;
import net.ivoa.xml.vospace.v2.Transfer;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DataSourceConfig.class})
@TestPropertySource(locations = "classpath:test.properties")
public class JobDAOTest {
@Autowired
private DataSource dataSource;
private JobDAO dao;
@BeforeEach
public void init() {
dao = new JobDAO(dataSource);
}
@Test
public void testJob() {
Transfer transfer = new Transfer();
transfer.setDirection("pushToVoSpace");
transfer.setTarget("vos://example.com!vospace/mynode");
JobSummary job = new JobSummary();
job.setJobId("123");
job.setOwnerId("owner");
job.setPhase(ExecutionPhase.PENDING);
JobSummary.JobInfo jobInfo = new JobSummary.JobInfo();
jobInfo.getAny().add(transfer);
job.setJobInfo(jobInfo);
dao.createJob(job);
assertTrue(dao.getJob("123").isPresent());
assertEquals(ExecutionPhase.PENDING, dao.getJob("123").get().getPhase());
job.setPhase(ExecutionPhase.EXECUTING);
dao.updateJob(job);
assertEquals(ExecutionPhase.EXECUTING, dao.getJob("123").get().getPhase());
}
}