@Test public void testCreateTag() throws FOMException, JSONException, FluidException, IOException { // Lets create a tag underneath the user's default root namespace Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername()); String newName = UUID.randomUUID().toString(); Tag newTag = testNamespace.createTag(newName, "This is a test tag", true); // if we successfully created a tag there'll be an id assertEquals(true, newTag.getId().length() > 0); testNamespace.getItem(); // not really needed assertEquals(true, TestUtils.contains(testNamespace.getTagNames(), newName)); newTag.delete(); testNamespace.getItem(); assertEquals(false, TestUtils.contains(testNamespace.getTagNames(), newName)); // Lets make sure validation works correctly... newName = "this is wrong"; // e.g. space is an invalid character String msg = ""; try { newTag = testNamespace.createTag(newName, "This is a test namespace", false); } catch (FOMException ex) { msg = ex.getMessage(); } assertEquals("Invalid name (incorrect characters or too long)", msg); // the new name is too long newName = "foobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspamfoobarbazhamandeggscheeseandpicklespamspamspamspam"; msg = ""; try { newTag = testNamespace.createTag(newName, "This is a test namespace", false); } catch (FOMException ex) { msg = ex.getMessage(); } assertEquals("Invalid name (incorrect characters or too long)", msg); }
@Test public void testDelete() throws FOMException, FluidException, JSONException, IOException { // Lets create a new namespace underneath the user's default root namespace Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername()); String newName = UUID.randomUUID().toString(); Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace"); assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName)); newNamespace.delete(); testNamespace.getItem(); assertEquals(false, TestUtils.contains(testNamespace.getNamespaceNames(), newName)); }
@Test public void testGetTagNames() throws FOMException, JSONException, FluidException, IOException { Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername()); String newName = UUID.randomUUID().toString(); Tag newTag = testNamespace.createTag(newName, "This is a test tag", true); // check the change happens at FluidDB testNamespace.getItem(); assertEquals(true, TestUtils.contains(testNamespace.getTagNames(), newName)); // delete the tag newTag.delete(); // this *won't* mean the tag is removed from the local object assertEquals(true, TestUtils.contains(testNamespace.getTagNames(), newName)); // need to update from FluidDB testNamespace.getItem(); assertEquals(false, TestUtils.contains(testNamespace.getTagNames(), newName)); }
@Test public void testGetNamespaceNames() throws FOMException, FluidException, JSONException, IOException { // Lets create a new namespace underneath the user's default root namespace Namespace testNamespace = new Namespace(this.fdb, "", this.fdb.getUsername()); String newName = UUID.randomUUID().toString(); Namespace newNamespace = testNamespace.createNamespace(newName, "This is a test namespace"); // check the change happens at FluidDB testNamespace.getItem(); assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName)); // delete the namespace newNamespace.delete(); // this *won't* mean the namespace is removed from the local object assertEquals(true, TestUtils.contains(testNamespace.getNamespaceNames(), newName)); // need to update from FluidDB testNamespace.getItem(); assertEquals(false, TestUtils.contains(testNamespace.getNamespaceNames(), newName)); }