/** Test of get method, of class SAMPFactory. */ public void testGet_SAMPMessage_Class() throws Exception { String mtype = "test"; Object instance = getInstance(); SAMPMessage message = SAMPFactory.createMessage(mtype, instance, TestInterface.class); TestInterface result = (TestInterface) SAMPFactory.get(message, TestInterface.class); assertEquals("Test Name", result.getName()); assertTrue(Arrays.equals(new double[] {1., 2., 3.}, result.getArray())); assertEquals("Test Something", result.getNested().getSomething()); }
/** Test of get method, of class SAMPFactory. */ public void testGet_Class() { TestInterface result = (TestInterface) SAMPFactory.get(TestInterface.class); List<String> methods = new ArrayList<>(); List<String> exp_methods = new ArrayList<>(); for (Method m : result.getClass().getDeclaredMethods()) methods.add(m.getName()); for (Method m : TestInterface.class.getDeclaredMethods()) exp_methods.add(m.getName()); assertTrue(methods.containsAll(exp_methods)); result.setName("test name"); result.setArray(new double[] {0.1, 0.2}); result.getNested().setSomething("test something"); assertEquals("test name", result.getName()); assertTrue(Arrays.equals(new double[] {0.1, 0.2}, result.getArray())); assertEquals("test something", result.getNested().getSomething()); result.addThing("Three"); assertTrue(result.getThings().contains("Three")); }