### Question:
AbstractDataSourceConverter implements Converter { @Override public void execute(CommandSender sender) { if (destinationType != destination.getType()) { if (sender != null) { sender.sendMessage("Please configure your connection to " + destinationType + " and re-run this command"); } return; } S source; try { source = getSource(); } catch (Exception e) { logAndSendMessage(sender, "The data source to convert from could not be initialized"); ConsoleLogger.logException("Could not initialize source:", e); return; } List<String> skippedPlayers = new ArrayList<>(); for (PlayerAuth auth : source.getAllAuths()) { if (destination.isAuthAvailable(auth.getNickname())) { skippedPlayers.add(auth.getNickname()); } else { adaptPlayerAuth(auth); destination.saveAuth(auth); destination.updateSession(auth); destination.updateQuitLoc(auth); } } if (!skippedPlayers.isEmpty()) { logAndSendMessage(sender, "Skipped conversion for players which were already in " + destinationType + ": " + String.join(", ", skippedPlayers)); } logAndSendMessage(sender, "Database successfully converted from " + source.getType() + " to " + destinationType); } AbstractDataSourceConverter(DataSource destination, DataSourceType destinationType); @Override void execute(CommandSender sender);  }### Answer:
@Test public void shouldThrowForDestinationTypeMismatch() { DataSource destination = mock(DataSource.class); given(destination.getType()).willReturn(DataSourceType.MYSQL); DataSourceType destinationType = DataSourceType.SQLITE; DataSource source = mock(DataSource.class); Converter converter = new DataSourceConverterTestImpl<>(source, destination, destinationType); CommandSender sender = mock(CommandSender.class); converter.execute(sender); verify(sender).sendMessage(argThat(containsString("Please configure your connection to SQLITE"))); verify(destination, only()).getType(); verifyZeroInteractions(source); }
@Test public void shouldConvertAndSkipExistingPlayers() { DataSource source = mock(DataSource.class); DataSource destination = mock(DataSource.class); DataSourceType destinationType = DataSourceType.MYSQL; given(destination.getType()).willReturn(destinationType); List<PlayerAuth> auths = Arrays.asList(mockAuthWithName("Steven"), mockAuthWithName("bobby"), mockAuthWithName("Jack")); given(source.getAllAuths()).willReturn(auths); given(destination.isAuthAvailable(auths.get(0).getNickname())).willReturn(true); Converter converter = new DataSourceConverterTestImpl<>(source, destination, destinationType); CommandSender sender = mock(CommandSender.class); converter.execute(sender); verify(destination).getType(); verify(destination, times(3)).isAuthAvailable(anyString()); verify(destination, times(2)).saveAuth(any(PlayerAuth.class)); verify(destination, times(2)).updateSession(any(PlayerAuth.class)); verify(destination, times(2)).updateQuitLoc(any(PlayerAuth.class)); verifyNoMoreInteractions(destination); verify(sender).sendMessage(argThat(containsString(auths.get(0).getNickname()))); verify(sender).sendMessage(argThat(containsString("successfully converted"))); }