use of org.onosproject.core.CoreService in project fabric-tna by stratum.
the class FabricUpfProgrammableTest method setUp.
@Before
public void setUp() throws Exception {
FabricCapabilities capabilities = createMock(FabricCapabilities.class);
expect(capabilities.supportUpf()).andReturn(true).anyTimes();
replay(capabilities);
// Services mock
packetService = new MockPacketService();
CoreService coreService = createMock(CoreService.class);
NetworkConfigService netcfgService = createMock(NetworkConfigService.class);
DeviceService deviceService = createMock(DeviceService.class);
SlicingService slicingService = createMock(SlicingService.class);
expect(slicingService.getSlices()).andReturn(Set.of(SliceId.of(SLICE_MOBILE))).anyTimes();
expect(slicingService.getTrafficClasses(SliceId.of(SLICE_MOBILE))).andReturn(Set.of(TrafficClass.ELASTIC)).anyTimes();
PiTranslationService piTranslationService = createMock(PiTranslationService.class);
expect(coreService.getAppId(anyString())).andReturn(APP_ID).anyTimes();
expect(netcfgService.getConfig(TestUpfConstants.DEVICE_ID, BasicDeviceConfig.class)).andReturn(TestUpfUtils.getBasicConfig(TestUpfConstants.DEVICE_ID, "/basic.json")).anyTimes();
replay(coreService, netcfgService, slicingService);
// Mock driverData to get the right device ID
DriverData driverData = createMock(DriverData.class);
expect(driverData.deviceId()).andReturn(TestUpfConstants.DEVICE_ID).anyTimes();
replay(driverData);
// Mock DriverHandler to get all the required mocked services
DriverHandler driverHandler = createMock(DriverHandler.class);
expect(driverHandler.get(FlowRuleService.class)).andReturn(new MockFlowRuleService()).anyTimes();
expect(driverHandler.get(MeterService.class)).andReturn(new MockMeterService()).anyTimes();
expect(driverHandler.get(SlicingService.class)).andReturn(slicingService).anyTimes();
expect(driverHandler.get(PacketService.class)).andReturn(packetService).anyTimes();
expect(driverHandler.get(NetworkConfigService.class)).andReturn(netcfgService).anyTimes();
expect(driverHandler.get(CoreService.class)).andReturn(coreService).anyTimes();
expect(driverHandler.get(DeviceService.class)).andReturn(deviceService).anyTimes();
expect(driverHandler.get(PiTranslationService.class)).andReturn(piTranslationService).anyTimes();
expect(driverHandler.get(PiPipeconfService.class)).andReturn(new MockPiPipeconfService(TABLE_MODELS, COUNTER_MODELS, METER_MODELS, TNA)).anyTimes();
expect(driverHandler.get(P4RuntimeController.class)).andReturn(mockP4RtController).anyTimes();
expect(driverHandler.data()).andReturn(driverData).anyTimes();
replay(driverHandler);
upfProgrammable = new FabricUpfProgrammable();
TestUtils.setField(upfProgrammable, "handler", driverHandler);
TestUtils.setField(upfProgrammable, "data", driverData);
ConcurrentMap<DeviceId, URI> channelUris = TestUtils.getField(upfProgrammable, "CHANNEL_URIS");
channelUris.put(TestUpfConstants.DEVICE_ID, new URI("grpc://localhost:1234?device_id=1"));
}
Aggregations