### Question:
Prodigy { public static String inject(String name, String params) { if (name == null) { throw new IllegalArgumentException("Parameter 'name' is required"); } if (params == null) { params = "{}"; } Fault fault = container.fault(name, params); if (fault == null) { throw new IllegalArgumentException("Fault cannot be instantiated with name [" + name + "] and params [" + params + "]"); } if (fault instanceof Validator) { Set<Violation> violations = ((Validator) fault).validate(); if (!violations.isEmpty()) { throw new IllegalArgumentException("Parameter 'params' is invalid: " + violations); } } log.info("Injecting fault id [" + fault.id() + "]"); boolean result = container.scheduler().schedule(fault); if (!result) { throw new IllegalArgumentException("Fault id [" + fault.id() + "] already exists"); } log.info("Fault id [" + fault.id() + "] injected"); return fault.id(); } private  Prodigy(); @SuppressWarnings("unchecked") static T adapt(T target); static String inject(String name, String params); static void eject(String id); static Map<String, Class<? extends Fault>> faults(); static Entry status(String id); static List<Entry> status(); static void push(String name, InputStream jar);  }### Answer:
@Test public void testInject() { try { Prodigy.inject(null, null); fail(); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Parameter 'name' is required")); } Container container = mock(Container.class); doReturn(null).when(container).fault(anyString(), anyString()); Prodigy.container(container); try { Prodigy.inject("fault-1", null); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Fault cannot be instantiated with name [fault-1] and params [{}]")); } container = mock(Container.class); doReturn(new Validator1()).when(container).fault(anyString(), anyString()); Prodigy.container(container); try { Prodigy.inject("fault-1", null); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Parameter 'params' is invalid: [message]")); } Scheduler scheduler = mock(Scheduler.class); doReturn(false).when(scheduler).schedule(ArgumentMatchers.any(Fault.class)); container = mock(Container.class); Fault fault = new Validator2(); fault.id("fault-id-2"); doReturn(fault).when(container).fault(anyString(), anyString()); doReturn(scheduler).when(container).scheduler(); Prodigy.container(container); try { Prodigy.inject("fault-2", null); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), is("Fault id [fault-id-2] already exists")); } scheduler = mock(Scheduler.class); doReturn(true).when(scheduler).schedule(ArgumentMatchers.any(Fault.class)); container = mock(Container.class); fault = new Validator2(); fault.id("fault-id-2"); Fault result = fault; doAnswer(i -> { assertThat(i.getArgument(1), is("{}")); return result; }).when(container).fault(anyString(), anyString()); doReturn(scheduler).when(container).scheduler(); Prodigy.container(container); String id = Prodigy.inject("fault-2", null); assertThat(id, is("fault-id-2")); scheduler = mock(Scheduler.class); doReturn(true).when(scheduler).schedule(ArgumentMatchers.any(Fault.class)); container = mock(Container.class); fault = new Validator2(); fault.id("fault-id-2"); doReturn(fault).when(container).fault(anyString(), anyString()); doReturn(scheduler).when(container).scheduler(); Prodigy.container(container); id = Prodigy.inject("fault-2", "{\"key-1\" : \"value-1\"}"); assertThat(id, is("fault-id-2")); }