### Question:
ServerFactoryUtil { static List<ConnectorFactory> extractConnectorFactories(ServerFactory serverFactory) { List<ConnectorFactory> connectorFactories = new ArrayList<>(); if (serverFactory instanceof DefaultServerFactory) { DefaultServerFactory defaultServerFactory = (DefaultServerFactory) serverFactory; connectorFactories.addAll(defaultServerFactory.getApplicationConnectors()); connectorFactories.addAll(defaultServerFactory.getAdminConnectors()); } else if (serverFactory instanceof SimpleServerFactory) { SimpleServerFactory simpleServerFactory = (SimpleServerFactory) serverFactory; connectorFactories.add(simpleServerFactory.getConnector()); } else if (serverFactory == null) { LOG.error( "Unable to apply secure connector config. Expecting a DefaultServerFactory or a SimpleServerFactory" + " but got null"); } else { LOG.error( "Unable to apply secure connector config. Expecting a DefaultServerFactory or a SimpleServerFactory" + " but found a {}", serverFactory.getClass()); } return connectorFactories; } private  ServerFactoryUtil();   }### Answer:
@Test public void extractNoConnectorsFromNull() { assertThat(ServerFactoryUtil.extractConnectorFactories(null)).isEmpty(); }
@Test public void extractNoConnectorsFromUnknownServerFactoryType() { assertThat(ServerFactoryUtil.extractConnectorFactories(mock(ServerFactory.class))).isEmpty(); }
@Test public void extractConnectorsFromSimpleServerFactory() { ConnectorFactory connectorFactoryMock = mock(ConnectorFactory.class); SimpleServerFactory simpleServerFactory = mock(SimpleServerFactory.class); when(simpleServerFactory.getConnector()).thenReturn(connectorFactoryMock); List<ConnectorFactory> actual = ServerFactoryUtil.extractConnectorFactories(simpleServerFactory); assertThat(actual).containsExactly(connectorFactoryMock); }
@Test public void extractConnectorsFromDefaultServerFactory() { ConnectorFactory firstAppConnector = mock(ConnectorFactory.class); ConnectorFactory secondAppConnector = mock(ConnectorFactory.class); ConnectorFactory adminConnector = mock(ConnectorFactory.class); DefaultServerFactory serverFactory = mock(DefaultServerFactory.class); when(serverFactory.getApplicationConnectors()) .thenReturn(asList(firstAppConnector, secondAppConnector)); when(serverFactory.getAdminConnectors()).thenReturn(singletonList(adminConnector)); List<ConnectorFactory> actual = ServerFactoryUtil.extractConnectorFactories(serverFactory); assertThat(actual).containsExactly(firstAppConnector, secondAppConnector, adminConnector); }