...
Test class example
Below is the example of test class which can be used as a template/reference for database tests being added to CPS project.
Code Block | ||
---|---|---|
| ||
package org.onap.cps.spi.impl;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.onap.cps.DatabaseTestContainer;
import org.onap.cps.spi.CpsAdminPersistenceService;
import org.onap.cps.spi.repository.DataspaceRepository;
import org.onap.cps.spi.repository.SchemaSetRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class CpsAdminPersistenceServiceTest {
private static final String CLEAR_DATA = "/data/clear-all.sql";
private static final String SET_DATA = "/data/anchor.sql";
@ClassRule
public static DatabaseTestContainer databaseTestContainer = DatabaseTestContainer.getInstance();
@Autowired
private CpsAdminPersistenceService cpsAdminPersistenceService;
@Autowired
private DataspaceRepository dataspaceRepository;
@Autowired
private SchemaSetRepository schemaSetRepository;
@Test
@Sql({CLEAR_DATA, SET_DATA})
public void testCreateAnchor() {
// test
}
}
|
Resources
Frameworks and libraries:
...