Search in sources :

Example 1 with FakeIntentManager

use of org.onosproject.net.intent.FakeIntentManager in project onos by opennetworkinglab.

the class IntentsResourceTest method testRemove.

/**
 * Tests removing an intent with DELETE.
 */
@Test
public void testRemove() {
    final HashSet<NetworkResource> resources = new HashSet<>();
    resources.add(new MockResource(1));
    resources.add(new MockResource(2));
    resources.add(new MockResource(3));
    final Intent intent = new MockIntent(3L, resources);
    final ApplicationId appId = new DefaultApplicationId(2, "app");
    IntentService fakeManager = new FakeIntentManager();
    expect(mockCoreService.getAppId("app")).andReturn(appId).once();
    replay(mockCoreService);
    mockIntentService.withdraw(anyObject());
    expectLastCall().andDelegateTo(fakeManager).once();
    expect(mockIntentService.getIntent(Key.of(2, appId))).andReturn(intent).once();
    expect(mockIntentService.getIntent(Key.of("0x2", appId))).andReturn(null).once();
    mockIntentService.addListener(anyObject());
    expectLastCall().andDelegateTo(fakeManager).once();
    mockIntentService.removeListener(anyObject());
    expectLastCall().andDelegateTo(fakeManager).once();
    replay(mockIntentService);
    WebTarget wt = target();
    Response response = wt.path("intents/app/0x2").request(MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN).delete();
    assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
}
Also used : NetworkResource(org.onosproject.net.NetworkResource) Response(javax.ws.rs.core.Response) IntentService(org.onosproject.net.intent.IntentService) FakeIntentManager(org.onosproject.net.intent.FakeIntentManager) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) HostToHostIntent(org.onosproject.net.intent.HostToHostIntent) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) WebTarget(javax.ws.rs.client.WebTarget) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) ApplicationId(org.onosproject.core.ApplicationId) MockIntent(org.onosproject.net.intent.IntentTestsMocks.MockIntent) DefaultApplicationId(org.onosproject.core.DefaultApplicationId) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 WebTarget (javax.ws.rs.client.WebTarget)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1 ApplicationId (org.onosproject.core.ApplicationId)1 DefaultApplicationId (org.onosproject.core.DefaultApplicationId)1 NetworkResource (org.onosproject.net.NetworkResource)1 ConnectivityIntent (org.onosproject.net.intent.ConnectivityIntent)1 FakeIntentManager (org.onosproject.net.intent.FakeIntentManager)1 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)1 HostToHostIntent (org.onosproject.net.intent.HostToHostIntent)1 Intent (org.onosproject.net.intent.Intent)1 IntentService (org.onosproject.net.intent.IntentService)1 MockIntent (org.onosproject.net.intent.IntentTestsMocks.MockIntent)1 PathIntent (org.onosproject.net.intent.PathIntent)1 PointToPointIntent (org.onosproject.net.intent.PointToPointIntent)1