Create an implementaion of IntentIdGenerator

- Define interface to allocate IdBlock in IdBlockAllocator
- Implement IdBlockAllocatorBasedIntentIdGenerator
- Refactor IdBlock class

Change-Id: I21fa21ae625e3d7e137a7f846bb5a0c1bdb8df9a
diff --git a/src/test/java/net/onrc/onos/core/registry/IdBlockTest.java b/src/test/java/net/onrc/onos/core/registry/IdBlockTest.java
new file mode 100644
index 0000000..aec55fa
--- /dev/null
+++ b/src/test/java/net/onrc/onos/core/registry/IdBlockTest.java
@@ -0,0 +1,33 @@
+package net.onrc.onos.core.registry;
+
+import net.onrc.onos.core.util.UnavailableIdException;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
+/**
+ * Suites of test of {@link IdBlock}.
+ */
+public class IdBlockTest {
+
+    private final IdBlock sut = new IdBlock(0, 3);
+
+    /**
+     * Tests generated sequences. Also checks occurrence of {@link UnavailableIdException},
+     * when the number of generated IDs exceeds the block size.
+     */
+    @Test
+    public void basics() {
+        assertThat(sut.getNextId(), is(0L));
+        assertThat(sut.getNextId(), is(1L));
+        assertThat(sut.getNextId(), is(2L));
+
+        try {
+            sut.getNextId();
+            fail("UnavailableIdException should be thrown");
+        } catch (UnavailableIdException e) {
+            assertTrue(true);
+        }
+    }
+}