@Before @Override public void setUp() { super.setUp(); List<Marshaller<?>> marshallers = new ArrayList<>(); when(marshallerInstance.iterator()).thenReturn(marshallers.iterator()); marshallerRegistry = new VFSMarshallerRegistry(marshallerInstance); ((VFSMarshallerRegistry) marshallerRegistry).init(); }
@Before @Override public void setUp() { super.setUp(); List<Marshaller<?>> marshallers = new ArrayList<>(); when(marshallerInstance.iterator()).thenReturn(marshallers.iterator()); marshallerRegistry = new VFSMarshallerRegistry(marshallerInstance); ((VFSMarshallerRegistry) marshallerRegistry).init(); }
@Test public void testInit() { //mock a set of marshallers List<Marshaller<?>> marshallers = new ArrayList<>(); Arrays.stream(marshallerClasses).forEach(clazz -> { Marshaller marshaller = mock(Marshaller.class); when(marshaller.getType()).thenReturn(clazz); marshallers.add(marshaller); }); when(marshallerInstance.iterator()).thenReturn(marshallers.iterator()); ((VFSMarshallerRegistry) marshallerRegistry).init(); for (int i = 0; i < marshallerClasses.length; i++) { Class clazz = marshallerClasses[i]; Marshaller marshaller = marshallerRegistry.get(clazz); assertNotNull(marshaller); assertEquals(clazz, marshaller.getType()); } } }
@Test public void testInit() { //mock a set of marshallers List<Marshaller<?>> marshallers = new ArrayList<>(); Arrays.stream(marshallerClasses).forEach(clazz -> { Marshaller marshaller = mock(Marshaller.class); when(marshaller.getType()).thenReturn(clazz); marshallers.add(marshaller); }); when(marshallerInstance.iterator()).thenReturn(marshallers.iterator()); ((VFSMarshallerRegistry) marshallerRegistry).init(); for (int i = 0; i < marshallerClasses.length; i++) { Class clazz = marshallerClasses[i]; Marshaller marshaller = marshallerRegistry.get(clazz); assertNotNull(marshaller); assertEquals(clazz, marshaller.getType()); } } }