### Question:
IntercomMetricCollector implements MetricCollector { @Override public void tagOrganisation(final String tagName, final MetricOrganisation metricOrganisation) { try { Tag.tag(new Tag().setName(tagName), new Company().setCompanyID(metricOrganisation.id())); } catch (final Exception e) { throw new MetricException( String.format("Error tagging Intercom organisation: %s - %s ", metricOrganisation, e.getMessage())); } } IntercomMetricCollector(final String personalAccessToken); @Override void createOrganisation(final MetricOrganisation organisation); @Override void updateOrganisation(final MetricOrganisation organisation); @Override void tagOrganisation(final String tagName, final MetricOrganisation metricOrganisation); @Override void createUser(final MetricUser user); @Override void updateUser(final MetricUser user); @Override void addCustomAttributesToUser(final String userId, final Map<String, Object> customAttributes); @Override void addOrganisationToUser(final String userId, final String organisationId); @Override void removeOrganisationFromUser(final String userId, final String organisationId); @Override void deleteUser(final String userId); @Override void sendMetric(final Metric metric); @Override MetricUser getUser(final String userId); @Override void convertExistingContactToUser(final String contactId, final MetricUser metricUser);  }### Answer:
@Test public void shouldTagIntercomOrganisation_withMetricOrganisation() throws Exception { final String tagName = randomString(); final MetricOrganisation metricOrganisation = randomMetricOrganisation(); intercomMetricCollector.tagOrganisation(tagName, metricOrganisation); final ArgumentCaptor<Tag> tagCaptor = ArgumentCaptor.forClass(Tag.class); final ArgumentCaptor<Company> companyCaptor = ArgumentCaptor.forClass(Company.class); verifyStatic(Tag.class); Tag.tag(tagCaptor.capture(), companyCaptor.capture()); assertThat(tagCaptor.getValue().getName(), is(tagName)); assertThat(companyCaptor.getValue().getCompanyID(), is(metricOrganisation.id())); }
@Test public void shouldNotTagIntercomOrganisation_withExceptionThrownDuringTagging() throws Exception { final String tagName = randomString(); final MetricOrganisation metricOrganisation = randomMetricOrganisation(); when(Tag.tag(any(Tag.class), any(Company.class))).thenThrow(IntercomException.class); MetricException thrownException = null; try { intercomMetricCollector.tagOrganisation(tagName, metricOrganisation); } catch (final MetricException e) { thrownException = e; } assertNotNull(thrownException); }