Package com.cloud.network.element

Examples of com.cloud.network.element.MidoNetElement


        @SuppressWarnings("unchecked")
        VirtualMachineProfile<? extends VirtualMachine> mockVm =
                (VirtualMachineProfile<? extends VirtualMachine>)mock(VirtualMachineProfile.class);
        when(mockVm.getType()).thenReturn(VirtualMachine.Type.User);

        MidoNetElement elem = new MidoNetElement();
        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        boolean result = false;
        try {
            result = elem.addDhcpEntry(mockNetwork, mockNic, mockVm, null, null);
        } catch (ConcurrentOperationException e) {
            fail(e.getMessage());
        } catch (InsufficientCapacityException e) {
            fail(e.getMessage());
        } catch (ResourceUnavailableException e) {
View Full Code Here


        //mockAccountDao
        AccountDao mockAccountDao = mock(AccountDao.class);
        AccountVO mockAccountVO = mock(AccountVO.class);
        when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
        when(mockAccountVO.getUuid()).thenReturn("1");
        MidoNetElement elem = new MidoNetElement();

        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        //mockRPort
        RouterPort mockRPort = mock(RouterPort.class);
        when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));

        //mockBPort
        BridgePort mockBPort = mock(BridgePort.class);
        when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);

        //mockPort
        Port mockPort = mock(Port.class);

        ResourceCollection<Port> peerPorts =
            new ResourceCollection<Port>(new ArrayList<Port>());

        peerPorts.add(mockPort);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
        when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
        when(mockNetwork.getId()).thenReturn((long)2);
        when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
        when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Public);

        boolean result = false;
        try {
            result = elem.implement(mockNetwork, null, null, null);
        } catch (ConcurrentOperationException e) {
            fail(e.getMessage());
        } catch (InsufficientCapacityException e) {
            fail(e.getMessage());
        } catch (ResourceUnavailableException e) {
View Full Code Here

        @SuppressWarnings("unchecked")
        VirtualMachineProfile mockVm =
                (VirtualMachineProfile)mock(VirtualMachineProfile.class);
        when(mockVm.getType()).thenReturn(VirtualMachine.Type.User);

        MidoNetElement elem = new MidoNetElement();
        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        boolean result = false;
        try {
            result = elem.addDhcpEntry(mockNetwork, mockNic, mockVm, null, null);
        } catch (ConcurrentOperationException e) {
            fail(e.getMessage());
        } catch (InsufficientCapacityException e) {
            fail(e.getMessage());
        } catch (ResourceUnavailableException e) {
View Full Code Here

        //mockAccountDao
        AccountDao mockAccountDao = mock(AccountDao.class);
        AccountVO mockAccountVO = mock(AccountVO.class);
        when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
        when(mockAccountVO.getUuid()).thenReturn("1");
        MidoNetElement elem = new MidoNetElement();

        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        //mockRPort
        RouterPort mockRPort = mock(RouterPort.class);
        when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));

        //mockBPort
        BridgePort mockBPort = mock(BridgePort.class);
        when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);

        //mockPort
        Port mockPort = mock(Port.class);

        ResourceCollection<Port> peerPorts =
            new ResourceCollection<Port>(new ArrayList<Port>());

        peerPorts.add(mockPort);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
        when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
        when(mockNetwork.getId()).thenReturn((long)2);
        when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
        when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Public);

        boolean result = false;
        try {
            result = elem.implement(mockNetwork, null, null, null);
        } catch (ConcurrentOperationException e) {
            fail(e.getMessage());
        } catch (InsufficientCapacityException e) {
            fail(e.getMessage());
        } catch (ResourceUnavailableException e) {
View Full Code Here

TOP

Related Classes of com.cloud.network.element.MidoNetElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.