public static ObjectMethodsDef[] filterMethods(ObjectMethodsDef[] initial) { ArrayList<ObjectMethodsDef> desiredDefs = new ArrayList<ObjectMethodsDef>(); for (ObjectMethodsDef def : initial) { if (!def.getServiceDefinitionPID().startsWith("fedora-system:") && def != null) { desiredDefs.add(def); } } return desiredDefs.toArray(new ObjectMethodsDef[0]); }
@Test public void testListMethods2() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_2_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Wrong number of methods!", 1, methods.length); assertEquals("Wrong method SDef!", SDEF_2_PID, methods[0] .getServiceDefinitionPID()); assertEquals("Wrong method", "content2", methods[0].getMethodName()); }
@Test public void testListMethods1() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_1_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Wrong number of methods", 1, methods.length); assertEquals("Wrong method SDep", SDEF_1_PID, methods[0] .getServiceDefinitionPID()); assertEquals("Wrong method", "content", methods[0].getMethodName()); }
@Test public void testListMethods() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Wrong number of methods", 1, methods.length); assertEquals(methods[0].getServiceDefinitionPID(), SDEF_PID); assertEquals(methods[0].getMethodName(), SDEF_METHOD); }
@Test public void testListMethods() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_1_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Wrong number of methods", 2, methods.length); assertNotSame("SDeps are not distinct", methods[0] .getServiceDefinitionPID(), methods[1] .getServiceDefinitionPID()); assertNotSame("Methods are not distinct", methods[0].getMethodName(), methods[1].getMethodName()); /* Order may not be deterministic, but that's OK */ if (methods[0].getServiceDefinitionPID().equals(SDEF_1_PID)) { assertEquals(methods[1].getServiceDefinitionPID(), SDEF_2_PID); assertEquals(methods[0].getMethodName(), SDEF_1_METHOD); assertEquals(methods[1].getMethodName(), SDEF_2_METHOD); } else if (methods[0].getServiceDefinitionPID().equals(SDEF_2_PID)) { assertEquals(methods[1].getServiceDefinitionPID(), SDEF_1_PID); assertEquals(methods[0].getMethodName(), SDEF_2_METHOD); assertEquals(methods[1].getMethodName(), SDEF_1_METHOD); } }
@Test public void testListMethods1_2() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_1_2_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Too many methods!", 2, methods.length); assertNotSame("SDefs are duplicated", methods[0] .getServiceDefinitionPID(), methods[1] .getServiceDefinitionPID()); assertNotSame("methods are duplicated", methods[0].getMethodName(), methods[1].getMethodName()); }
@Test public void testListMethods3() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_3_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Too many methods!", 2, methods.length); assertNotSame("SDefs are duplicated", methods[0] .getServiceDefinitionPID(), methods[1] .getServiceDefinitionPID()); assertNotSame("methods are duplicated", methods[0].getMethodName(), methods[1].getMethodName()); }
@Test public void testListMethods4() throws Exception { FedoraAPIAMTOM apia = s_client.getAPIAMTOM(); ObjectMethodsDef[] methods; methods = filterMethods(apia.listMethods(OBJECT_4_PID, null).toArray(new ObjectMethodsDef[0])); assertEquals("Too many methods!", 3, methods.length); assertNotSame("SDefs are duplicated", methods[0] .getServiceDefinitionPID(), methods[1] .getServiceDefinitionPID()); assertNotSame("SDefs are duplicated", methods[0] .getServiceDefinitionPID(), methods[2] .getServiceDefinitionPID()); assertNotSame("SDefs are duplicated", methods[1] .getServiceDefinitionPID(), methods[2] .getServiceDefinitionPID()); assertNotSame("methods are duplicated", methods[0].getMethodName(), methods[1].getMethodName()); assertNotSame("methods are duplicated", methods[0].getMethodName(), methods[2].getMethodName()); assertNotSame("methods are duplicated", methods[1].getMethodName(), methods[2].getMethodName()); }