/** * Create an instance of {@link ObjectMethodsDef } * */ public ObjectMethodsDef createObjectMethodsDef() { return new ObjectMethodsDef(); }
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]); }
public static List<org.fcrepo.server.types.gen.ObjectMethodsDef> convertObjectMethodsDefArrayToGenObjectMethodsDefList(org.fcrepo.server.storage.types.ObjectMethodsDef[] objectMethodDefs) { if (objectMethodDefs != null) { List<org.fcrepo.server.types.gen.ObjectMethodsDef> genObjectMethodDefs = new ArrayList<org.fcrepo.server.types.gen.ObjectMethodsDef>(objectMethodDefs.length); for (org.fcrepo.server.storage.types.ObjectMethodsDef objectMethodsDef : objectMethodDefs) { org.fcrepo.server.types.gen.ObjectMethodsDef genObjectMethodDef = new org.fcrepo.server.types.gen.ObjectMethodsDef(); genObjectMethodDef.setPID(objectMethodsDef.PID); genObjectMethodDef .setServiceDefinitionPID(objectMethodsDef.sDefPID); genObjectMethodDef.setMethodName(objectMethodsDef.methodName); org.fcrepo.server.storage.types.MethodParmDef[] methodParmDefs = objectMethodsDef.methodParmDefs; org.fcrepo.server.types.gen.ObjectMethodsDef.MethodParmDefs genMethodParmDefs = new org.fcrepo.server.types.gen.ObjectMethodsDef.MethodParmDefs(); if (methodParmDefs != null) { for (org.fcrepo.server.storage.types.MethodParmDef methodParmDef : methodParmDefs) { genMethodParmDefs .getMethodParmDef() .add(convertMethodParmDefToGenMethodParmDef(methodParmDef)); } } genObjectMethodDef.setMethodParmDefs(genMethodParmDefs); genObjectMethodDefs.add(genObjectMethodDef); } return genObjectMethodDefs; } else { return null; } }
@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); } }
public static List<org.fcrepo.server.types.gen.ObjectMethodsDef> convertObjectMethodsDefArrayToGenObjectMethodsDefList(org.fcrepo.server.storage.types.ObjectMethodsDef[] objectMethodDefs) { if (objectMethodDefs != null) { List<org.fcrepo.server.types.gen.ObjectMethodsDef> genObjectMethodDefs = new ArrayList<org.fcrepo.server.types.gen.ObjectMethodsDef>(objectMethodDefs.length); for (org.fcrepo.server.storage.types.ObjectMethodsDef objectMethodsDef : objectMethodDefs) { org.fcrepo.server.types.gen.ObjectMethodsDef genObjectMethodDef = new org.fcrepo.server.types.gen.ObjectMethodsDef(); genObjectMethodDef.setPID(objectMethodsDef.PID); genObjectMethodDef .setServiceDefinitionPID(objectMethodsDef.sDefPID); genObjectMethodDef.setMethodName(objectMethodsDef.methodName); org.fcrepo.server.storage.types.MethodParmDef[] methodParmDefs = objectMethodsDef.methodParmDefs; org.fcrepo.server.types.gen.ObjectMethodsDef.MethodParmDefs genMethodParmDefs = new org.fcrepo.server.types.gen.ObjectMethodsDef.MethodParmDefs(); if (methodParmDefs != null) { for (org.fcrepo.server.storage.types.MethodParmDef methodParmDef : methodParmDefs) { genMethodParmDefs .getMethodParmDef() .add(convertMethodParmDefToGenMethodParmDef(methodParmDef)); } } genObjectMethodDef.setMethodParmDefs(genMethodParmDefs); genObjectMethodDefs.add(genObjectMethodDef); } return genObjectMethodDefs; } else { return null; } }
@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()); }
/** * Create an instance of {@link ObjectMethodsDef } * */ public ObjectMethodsDef createObjectMethodsDef() { return new ObjectMethodsDef(); }
@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 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()); }