Search in sources :

Example 1 with BeforeTransaction

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);
        }
    }
}
Also used : OnmsCategory(org.opennms.netmgt.model.OnmsCategory) HashMap(java.util.HashMap) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 2 with BeforeTransaction

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());
}
Also used : App(com.ctrip.framework.apollo.common.entity.App) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 3 with BeforeTransaction

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);
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) AdapterOperationSchedule(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperationSchedule) AdapterOperation(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 4 with BeforeTransaction

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));
    }
}
Also used : NetworkBuilder(org.opennms.netmgt.model.NetworkBuilder) AdapterOperationSchedule(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperationSchedule) AdapterOperation(org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Example 5 with BeforeTransaction

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());
    });
}
Also used : XmEntity(com.icthh.xm.ms.entity.domain.XmEntity) Profile(com.icthh.xm.ms.entity.domain.Profile) BeforeTransaction(org.springframework.test.context.transaction.BeforeTransaction)

Aggregations

BeforeTransaction (org.springframework.test.context.transaction.BeforeTransaction)5 NetworkBuilder (org.opennms.netmgt.model.NetworkBuilder)2 AdapterOperation (org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperation)2 AdapterOperationSchedule (org.opennms.netmgt.provision.SimpleQueuedProvisioningAdapter.AdapterOperationSchedule)2 App (com.ctrip.framework.apollo.common.entity.App)1 Profile (com.icthh.xm.ms.entity.domain.Profile)1 XmEntity (com.icthh.xm.ms.entity.domain.XmEntity)1 HashMap (java.util.HashMap)1 OnmsCategory (org.opennms.netmgt.model.OnmsCategory)1