### Question:
AliasedPrinterResolver implements PrinterResolver { @Override public Printer resolve(String name) { Printer printer = printers.get(name); return nonNull(printer) ? printer : printers.get(aliases.get(name)); } AliasedPrinterResolver(Map<String, Printer> printers,
                                  Map<String, String> aliases); @Override Printer resolve(String name); @Override Printer resolve(String name, Class<?> printableClass); @Override List<Printer> resolve(String name, Class<?>[] printableClasses);  }### Answer:
@Test public void resolveByEmptyPrinterName() { String printerName = ""; Class<?> parameterType = String.class; Printer printer = printerResolver.resolve(printerName, parameterType); assertThat(printer.print("input"), is("0")); }
@Test public void resolveByEmptyPrinterNameAndUnexpectedType() { String printerName = ""; Class<?> parameterType = Boolean.class; Printer printer = printerResolver.resolve(printerName, parameterType); assertNull(printer); }
@Test public void resolveByUnknownPrinterName() { String printerName = "unknown"; Class<?> parameterType = String.class; Printer printer = printerResolver.resolve(printerName, parameterType); assertThat(printer.print("input"), is("0")); }
@Test public void resolveByAlias() { String printerName = "two2"; Class<?> parameterType = String.class; Printer printer = printerResolver.resolve(printerName, parameterType); assertThat(printer.print("input"), is("2")); }
@Test public void resolve() { String printerName = "two"; Class<?> parameterType = String.class; Printer printer = printerResolver.resolve(printerName, parameterType); assertThat(printer.print("input"), is("2")); }
@Test public void resolveByPrinterNameAndParameterTypes() { String printerName = "two"; Class<?>[] parameterTypes = new Class[]{String.class, Integer.class}; List<Printer> printers = printerResolver.resolve(printerName, parameterTypes); assertThat(printers, hasSize(2)); assertThat(printers.get(0).print("input"), is("2")); assertThat(printers.get(1).print("input"), is("1")); }
@Test public void resolveByParameterTypes() { String printerName = ""; Class<?>[] parameterTypes = new Class[]{String.class, Integer.class}; List<Printer> printers = printerResolver.resolve(printerName, parameterTypes); assertThat(printers, hasSize(2)); assertThat(printers.get(0).print("input"), is("0")); assertThat(printers.get(1).print("input"), is("1")); }
@Test public void resolveByParameterTypesDefault() { String printerName = ""; Class<?>[] parameterTypes = new Class[]{String.class, Integer.class, Throwable.class}; List<Printer> printers = printerResolver.resolve(printerName, parameterTypes); assertThat(printers, hasSize(3)); assertThat(printers.get(0).print("input"), is("0")); assertThat(printers.get(1).print("input"), is("1")); assertNull(printers.get(2)); }