TeamCityPlugin implements VisuwallPlugin<TeamCityConnection> { @Override public SoftwareId getSoftwareId(URL url, Map<String, String> properties) throws SoftwareNotFoundException { Preconditions.checkNotNull(url, "url is mandatory"); try { GenericSoftwareClient genericSoftwareClient = new GenericSoftwareClient("guest", ""); if (properties.get("login") != null) { genericSoftwareClient = new GenericSoftwareClient(properties.get("login"), properties.get("password")); } TeamCityServer teamCityServer = genericSoftwareClient.resource(url + "/app/rest/server", TeamCityServer.class); return createSoftwareId(teamCityServer); } catch (ResourceNotFoundException e) { throw new SoftwareNotFoundException("Url " + url + " is not compatible with TeamCity", e); } }  @Override TeamCityConnection getConnection(URL url, Map<String, String> properties); @Override Class<TeamCityConnection> getConnectionClass(); @Override String getName(); @Override float getVersion(); @Override SoftwareId getSoftwareId(URL url, Map<String, String> properties); @Override String toString(); @Override Map<String, String> getPropertiesWithDefaultValue();  }
@Test(expected = NullPointerException.class) public void should_thrown_an_exception_when_passing_null_to_is_jenkins_instance() throws SoftwareNotFoundException { new TeamCityPlugin().getSoftwareId(null, properties); }
@Test(expected = SoftwareNotFoundException.class) public void should_throw_exception_when_software_is_not_compatible() throws Exception { Throwable notFound = new ResourceNotFoundException("not found"); when(genericSoftwareClient.resource(anyString(), any(Class.class))).thenThrow(notFound); plugin.getSoftwareId(teamcityUrl, properties); }