Detangling incubator: virtual nets, tunnels, resource labels, oh my

- virtual networking moved to /apps/virtual; with CLI & REST API
- tunnels and labels moved to /apps/tunnel; with CLI & REST API; UI disabled for now
- protobuf/models moved to /core/protobuf/models
- defunct grpc/rpc registry stuff left under /graveyard
- compile dependencies on /incubator moved to respective modules for compilation
- run-time dependencies will need to be re-tested for dependent apps

- /graveyard will be removed in not-too-distant future

Change-Id: I0a0b995c635487edcf95a352f50dd162186b0b39
diff --git a/core/api/src/test/java/org/onosproject/alarm/AlarmEntityIdTest.java b/core/api/src/test/java/org/onosproject/alarm/AlarmEntityIdTest.java
new file mode 100644
index 0000000..25a145b
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/alarm/AlarmEntityIdTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.alarm;
+
+import com.google.common.testing.EqualsTester;
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.alarm.AlarmEntityId.alarmEntityId;
+
+/**
+ * Test of the alarm source identifier.
+ *
+ */
+public class AlarmEntityIdTest {
+
+    /**
+     * Checks that the class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(AlarmEntityId.class);
+    }
+
+    @Test
+    public void string() {
+        assertEquals("och:foo",
+                alarmEntityId("och:foo").toString());
+    }
+
+    @Test
+    public void basics() {
+        new EqualsTester()
+                .addEqualityGroup(
+                        alarmEntityId("och:foo"),
+                        alarmEntityId("och:foo"))
+                .addEqualityGroup(alarmEntityId("och:bar"))
+                .testEquals();
+
+    }
+
+    @Test
+    public void validSchemaPermitted() {
+        alarmEntityId("none:foo");
+        alarmEntityId("port:foo");
+        alarmEntityId("och:foo");
+        alarmEntityId("other:foo");
+
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void verifyUnexpectedSchemaRejected() {
+        alarmEntityId("junk:foo");
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void verifyCorruptSchemaRejected() {
+        alarmEntityId("other:");
+    }
+
+}
diff --git a/core/api/src/test/java/org/onosproject/alarm/AlarmIdTest.java b/core/api/src/test/java/org/onosproject/alarm/AlarmIdTest.java
new file mode 100644
index 0000000..a37c3cb
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/alarm/AlarmIdTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.alarm;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Test;
+import org.onosproject.net.DeviceId;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * This class tests the immutability, equality, and non-equality of {@link AlarmId}.
+ */
+public class AlarmIdTest {
+
+    private static final DeviceId DEVICE_ID = DeviceId.deviceId("foo:bar");
+    private static final String UNIQUE_ID_1 = "unique_id_1";
+    private static final AlarmId ID_A = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+
+    private static final String UNIQUE_ID_2 = "unique_id_2";
+
+    private static final String UNIQUE_ID_3 = "unique_id_3";
+    private static final AlarmId ID_Z = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_3);
+
+    private static final String ID_STRING = "foo:bar:unique_id_3";
+
+    /**
+     * Tests the immutability of {@link AlarmId}.
+     */
+    @Test
+    public void intentIdFollowsGuidelineForImmutableObject() {
+        assertThatClassIsImmutable(AlarmId.class);
+    }
+
+    /**
+     * Tests equality of {@link AlarmId}.
+     */
+    @Test
+    public void testEquality() {
+        final AlarmId id1 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+        final AlarmId id2 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+
+        assertThat(id1, is(id2));
+    }
+
+    /**
+     * Tests non-equality of {@link AlarmId}.
+     */
+    @Test
+    public void testNonEquality() {
+        final AlarmId id1 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+        final AlarmId id2 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_2);
+
+        assertThat(id1, is(not(id2)));
+    }
+
+    @Test
+    public void valueOf() {
+        final AlarmId id = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+        assertEquals("incorrect valueOf", id, ID_A);
+    }
+
+    /**
+     * Tests the equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+        final AlarmId id1 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+        final AlarmId sameAsId1 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+        final AlarmId id2 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_2);
+
+        new EqualsTester()
+                .addEqualityGroup(id1, sameAsId1)
+                .addEqualityGroup(id2)
+                .testEquals();
+    }
+
+    /**
+     * Tests construction of an AlarmId object.
+     */
+    @Test
+    public void testConstruction() {
+        final AlarmId id1 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_3);
+        assertEquals(id1.toString(), ID_Z.toString());
+
+        final AlarmId idString = AlarmId.alarmId(ID_STRING);
+        assertEquals(id1, idString);
+
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/alarm/AlarmProviderRegistryAdapter.java b/core/api/src/test/java/org/onosproject/alarm/AlarmProviderRegistryAdapter.java
new file mode 100644
index 0000000..f4075e5
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/alarm/AlarmProviderRegistryAdapter.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.alarm;
+
+import org.onosproject.net.provider.ProviderId;
+
+import java.util.Set;
+
+/**
+ * Adapter for Alarm Provider Registry.
+ */
+public class AlarmProviderRegistryAdapter implements AlarmProviderRegistry {
+
+    @Override
+    public AlarmProviderService register(AlarmProvider provider) {
+        return null;
+    }
+
+    @Override
+    public void unregister(AlarmProvider provider) {
+
+    }
+
+    @Override
+    public Set<ProviderId> getProviders() {
+        return null;
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/alarm/DefaultAlarmTest.java b/core/api/src/test/java/org/onosproject/alarm/DefaultAlarmTest.java
new file mode 100644
index 0000000..6818ef9
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/alarm/DefaultAlarmTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.alarm;
+
+import org.junit.Test;
+import org.onosproject.net.DeviceId;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+public class DefaultAlarmTest {
+
+    private static final AlarmEntityId ALARM_ENTITY_ID = AlarmEntityId.alarmEntityId("port:bar");
+    private static final DeviceId DEVICE_ID = DeviceId.deviceId("foo:bar");
+    private static final String UNIQUE_ID_1 = "unique_id_1";
+    private static final AlarmId ALARM_ID = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_1);
+    private static final String UNIQUE_ID_2 = "unique_id_1";
+    private static final AlarmId ALARM_ID_2 = AlarmId.alarmId(DEVICE_ID, UNIQUE_ID_2);
+
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(DefaultAlarm.class);
+    }
+
+    /**
+     * Checks the construction of a DefaultAlarm object.
+     */
+    @Test
+    public void testConstruction() {
+        final DefaultAlarm a = generate();
+        assertThat(a, is(notNullValue()));
+        final DefaultAlarm b = new DefaultAlarm.Builder(a).build();
+        assertEquals(a, b);
+    }
+
+    @Test
+    public void testEquals() {
+        final DefaultAlarm a = new DefaultAlarm.Builder(ALARM_ID_2,
+                DeviceId.NONE, "desc", Alarm.SeverityLevel.MINOR, 3).build();
+        final DefaultAlarm b = new DefaultAlarm.Builder(ALARM_ID,
+                DeviceId.NONE, "desc", Alarm.SeverityLevel.MINOR, a.timeRaised() + 1)
+                .withTimeUpdated(a.timeUpdated() + 1).build();
+        assertEquals("id or timeRaised or timeUpdated may differ", a, b);
+
+        assertNotEquals(a, new DefaultAlarm.Builder(a).withAcknowledged(!a.acknowledged()).build());
+        assertNotEquals(a, new DefaultAlarm.Builder(a).withManuallyClearable(!a.manuallyClearable()).build());
+        assertNotEquals(a, new DefaultAlarm.Builder(a).withServiceAffecting(!a.serviceAffecting()).build());
+        assertNotEquals(a, new DefaultAlarm.Builder(a).withAssignedUser("Changed" + a.assignedUser()).build());
+
+    }
+
+    @Test
+    public void testClear() {
+        final DefaultAlarm active = generate();
+        final DefaultAlarm cleared = new DefaultAlarm.Builder(active).clear().build();
+        assertNotEquals(active, cleared);
+        assertThat(cleared.timeRaised(), is(active.timeRaised()));
+        assertThat(cleared.severity(), is(Alarm.SeverityLevel.CLEARED));
+        assertThat(cleared.timeUpdated(), greaterThan(active.timeUpdated()));
+        assertNotNull(cleared.timeCleared());
+
+    }
+
+    @Test
+    public void testId() {
+        final DefaultAlarm a = generate();
+        final DefaultAlarm b = new DefaultAlarm.Builder(a).build();
+
+        assertEquals("id ignored in equals", a, b);
+        assertEquals(ALARM_ID, a.id());
+        assertEquals(ALARM_ID, b.id());
+        assertEquals(ALARM_ENTITY_ID, b.source());
+
+    }
+
+    private static DefaultAlarm generate() {
+        return new DefaultAlarm.Builder(ALARM_ID,
+                DeviceId.NONE, "desc", Alarm.SeverityLevel.MINOR, 3).forSource(ALARM_ENTITY_ID).build();
+    }
+}