Search in sources :

Example 1 with AffinityGroupService

use of org.apache.cloudstack.affinity.AffinityGroupService in project cloudstack by apache.

the class IntegrationTestConfiguration method affinityGroupService.

@Bean
public AffinityGroupService affinityGroupService() {
    AffinityGroupService mock = Mockito.mock(AffinityGroupService.class);
    try {
        final AffinityGroupVO gmock = new AffinityGroupVO("grp1", "grp-type", "affinity group", 1, Account.ACCOUNT_ID_SYSTEM, ControlledEntity.ACLType.Account);
        Transaction.execute(new TransactionCallbackNoReturn() {

            @Override
            public void doInTransactionWithoutResult(TransactionStatus status) {
                _affinityGroupDao.persist(gmock);
            }
        });
        Mockito.when(mock.createAffinityGroup(Matchers.any(String.class), Matchers.any(Long.class), Matchers.any(Long.class), Matchers.any(String.class), Matchers.any(String.class), Matchers.any(String.class))).thenReturn(gmock);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mock;
}
Also used : AffinityGroupVO(org.apache.cloudstack.affinity.AffinityGroupVO) AffinityGroupService(org.apache.cloudstack.affinity.AffinityGroupService) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) IOException(java.io.IOException) Bean(org.springframework.context.annotation.Bean)

Aggregations

TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)1 TransactionStatus (com.cloud.utils.db.TransactionStatus)1 IOException (java.io.IOException)1 AffinityGroupService (org.apache.cloudstack.affinity.AffinityGroupService)1 AffinityGroupVO (org.apache.cloudstack.affinity.AffinityGroupVO)1 Bean (org.springframework.context.annotation.Bean)1