use of org.springframework.test.context.transaction.BeforeTransaction in project opennms by OpenNMS.
the class HeatMapIT method setUp.
@BeforeTransaction
public void setUp() {
if (!m_populated) {
m_databasePopulator.populateDatabase();
m_populated = true;
}
numberOfNodesInCategory = new HashMap();
List<OnmsCategory> onmsCategories = m_categoryDao.findAll();
for (OnmsCategory onmsCategory : onmsCategories) {
int n = m_nodeDao.findByCategory(onmsCategory).size();
if (n > 0) {
numberOfNodesInCategory.put(onmsCategory.getName(), n);
}
}
}
use of org.springframework.test.context.transaction.BeforeTransaction in project apollo by ctripcorp.
the class AdminServiceTransactionTest method verifyInitialDatabaseState.
@BeforeTransaction
public void verifyInitialDatabaseState() {
for (App app : appRepository.findAll()) {
System.out.println(app.getAppId());
}
Assert.assertEquals(0, appRepository.count());
Assert.assertEquals(7, appNamespaceRepository.count());
Assert.assertEquals(0, namespaceRepository.count());
Assert.assertEquals(0, clusterRepository.count());
}
use of org.springframework.test.context.transaction.BeforeTransaction in project opennms by OpenNMS.
the class AbstractSingleHardwareAdapterTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@BeforeTransaction
public void setUp() throws Exception {
MockLogAppender.setupLogging(true);
NetworkBuilder nb = new NetworkBuilder();
nb.addNode("Test").setForeignSource("Test").setForeignId("1").setSysObjectId(".1.3.6.1.4.1.9.1.1196");
nb.addInterface("192.168.0.1").setIsSnmpPrimary("P").setIsManaged("P");
m_nodeDao.save(nb.getCurrentNode());
m_nodeDao.flush();
m_adapter.afterPropertiesSet();
m_nodeId = m_nodeDao.findByForeignId("Test", "1").getId();
AdapterOperationSchedule ops = new AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS);
m_operation = m_adapter.new AdapterOperation(m_nodeId, AdapterOperationType.ADD, ops);
}
use of org.springframework.test.context.transaction.BeforeTransaction in project opennms by OpenNMS.
the class SnmpHardwareInventoryProvisioningAdapterIT method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@BeforeTransaction
public void setUp() throws Exception {
MockLogAppender.setupLogging(true);
NetworkBuilder nb = new NetworkBuilder();
nb.addNode("R1").setForeignSource("Cisco").setForeignId("1").setSysObjectId(".1.3.6.1.4.1.9.1.222");
nb.addInterface("192.168.0.1").setIsSnmpPrimary("P").setIsManaged("P");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("R2").setForeignSource("Cisco").setForeignId("2").setSysObjectId(".1.3.6.1.4.1.9.1.222");
nb.addInterface("192.168.0.2").setIsSnmpPrimary("P").setIsManaged("P");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("R3").setForeignSource("Cisco").setForeignId("3").setSysObjectId(".1.3.6.1.4.1.9.1.222");
nb.addInterface("192.168.0.3").setIsSnmpPrimary("P").setIsManaged("P");
m_nodeDao.save(nb.getCurrentNode());
nb.addNode("R4").setForeignSource("Cisco").setForeignId("4").setSysObjectId(".1.3.6.1.4.1.9.1.222");
nb.addInterface("192.168.0.4").setIsSnmpPrimary("P").setIsManaged("P");
m_nodeDao.save(nb.getCurrentNode());
m_nodeDao.flush();
m_adapter.afterPropertiesSet();
for (int i = 1; i <= 4; i++) {
Integer nodeId = m_nodeDao.findByForeignId("Cisco", Integer.toString(i)).getId();
AdapterOperationSchedule ops = new AdapterOperationSchedule(0, 1, 1, TimeUnit.SECONDS);
AdapterOperation op = m_adapter.new AdapterOperation(nodeId, AdapterOperationType.ADD, ops);
m_operations.add(new TestOperation(nodeId, op));
}
}
use of org.springframework.test.context.transaction.BeforeTransaction in project xm-ms-entity by xm-online.
the class EntityServiceImplIntTest method beforeTransaction.
@BeforeTransaction
public void beforeTransaction() {
TenantContextUtils.setTenant(tenantContextHolder, "RESINTTEST");
MockitoAnnotations.initMocks(this);
when(authContextHolder.getContext()).thenReturn(context);
when(context.getRequiredUserKey()).thenReturn("userKey");
XmEntity sourceEntity = xmEntityRepository.save(createEntity(1l, TARGET_TYPE_KEY));
self = new Profile();
self.setXmentity(sourceEntity);
when(profileService.getSelfProfile()).thenReturn(self);
xmEntityService = new XmEntityServiceImpl(xmEntitySpecService, xmEntityRepository, xmEntitySearchRepository, lifecycleService, null, profileService, linkService, storageService, attachmentService, permittedSearchRepository, startUpdateDateGenerationStrategy, authContextHolder);
xmEntityService.setSelf(xmEntityService);
lepManager.beginThreadContext(ctx -> {
ctx.setValue(THREAD_CONTEXT_KEY_TENANT_CONTEXT, tenantContextHolder.getContext());
ctx.setValue(THREAD_CONTEXT_KEY_AUTH_CONTEXT, authContextHolder.getContext());
});
}
Aggregations