@Test public void shouldParseTypeCorrectly() throws Exception { String contactXml = "<tmNotice:contact type=\"agent\" />"; TmContact tmContact = tmContactXmlParser.parse(nodeForString(contactXml)); assertThat(tmContact, sameInstance(mockTmContact)); verify(mockTmContact).setType("agent"); }
@Test public void shouldParseEmailCorrectly() throws Exception { String contactXml = "<tmNotice:contact entitlement=\"owner\">" + "<tmNotice:email>[email protected]</tmNotice:email>" + "</tmNotice:contact>"; tmContactXmlParser.parse(nodeForString(contactXml)); verify(mockTmContact).setEmail("*****@*****.**"); }
@Test public void shouldParseOrganisationCorrectly() throws Exception { String contactXml = "<tmNotice:contact entitlement=\"owner\">" + "<tmNotice:org>Example Organisation One</tmNotice:org>" + "</tmNotice:contact>"; tmContactXmlParser.parse(nodeForString(contactXml)); verify(mockTmContact).setOrganisation("Example Organisation One"); }
@Test public void shouldParseFaxCorrectly() throws Exception { String contactXml = "<tmNotice:contact entitlement=\"owner\">" + "<tmNotice:fax x=\"4321\">+1.7035555555</tmNotice:fax>" + "</tmNotice:contact>"; tmContactXmlParser.parse(nodeForString(contactXml)); verify(mockTmContact).setFax("+1.7035555555"); verify(mockTmContact).setFaxExtension("4321"); }
@Test public void shouldParseAddressCorrectly() throws Exception { String contactXml = "<tmNotice:contact entitlement=\"owner\">" + "<tmNotice:addr />" + "</tmNotice:contact>"; TmAddressXmlParser mockTmAddressXmlParser = mock(TmAddressXmlParser.class); whenNew(TmAddressXmlParser.class).withNoArguments().thenReturn(mockTmAddressXmlParser); TmAddress mockTmAddress = mock(TmAddress.class); when(mockTmAddressXmlParser.parse(isNodeForXml("<tmNotice:addr />"))).thenReturn(mockTmAddress); tmContactXmlParser.parse(nodeForString(contactXml)); verify(mockTmContact).setAddress(mockTmAddress); }