@Test
void checkListenPortXmlElements() {

    ListenPortEntityBuilder builder = new ListenPortEntityBuilder(new IdGenerator());
    Service service = new Service();
    service.setId(ID_GENERATOR.generate());
    final Bundle bundle = new Bundle();
    bundle.putAllServices(ImmutableMap.of(SERVICE_REFERENCE, service));
    PrivateKey privateKey = new PrivateKey();
    privateKey.setId(ID_GENERATOR.generate());
    bundle.putAllPrivateKeys(ImmutableMap.of(PRIVATE_KEY, privateKey));
    final ListenPort listenPort = buildPortWithAllOptions();
    final ListenPortTlsSettings tlsSettings = listenPort.getTlsSettings();
    final Entity entity = builder.buildListenPortEntity(bundle, TEST_HTTP_PORT_NAME, listenPort, DocumentTools.INSTANCE.getDocumentBuilder().newDocument());
    assertNotNull(entity.getXml());
    assertNotNull(entity.getId());
    final Element xml = entity.getXml();
    // check if we have the correct amount of elements
    assertNotNull(xml.getAttribute(ATTRIBUTE_ID));
    assertNotNull(getSingleChildElement(xml, NAME));
    assertNotNull(getSingleChildElement(xml, ENABLED));
    assertNotNull(getSingleChildElement(xml, PROTOCOL));
    assertNotNull(getSingleChildElement(xml, PORT));
    assertNotNull(getSingleChildElement(xml, ENABLED_FEATURES));
    assertNotNull(getChildElements(getSingleChildElement(xml, ENABLED_FEATURES), STRING_VALUE));
    assertFalse(getChildElements(getSingleChildElement(xml, ENABLED_FEATURES), STRING_VALUE).isEmpty());
    assertNotNull(getSingleChildElement(xml, TARGET_SERVICE_REFERENCE));
    assertNotNull(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), CLIENT_AUTHENTICATION));
    assertNotNull(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), PRIVATE_KEY_REFERENCE));
    assertNotNull(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_VERSIONS));
    assertFalse(getChildElements(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_VERSIONS), STRING_VALUE).isEmpty());
    assertNotNull(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_CIPHER_SUITES));
    assertFalse(getChildElements(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_CIPHER_SUITES), STRING_VALUE).isEmpty());
    assertNotNull(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), PROPERTIES));
    assertNotNull(getSingleChildElement(xml, PROPERTIES));
    // then check contents
    assertEquals(entity.getId(), xml.getAttribute(ATTRIBUTE_ID));
    assertEquals(TEST_HTTP_PORT_NAME, getSingleChildElementTextContent(xml, NAME));
    assertEquals(TRUE.toString(), getSingleChildElementTextContent(xml, ENABLED));
    assertEquals(listenPort.getProtocol(), getSingleChildElementTextContent(xml, PROTOCOL));
    assertEquals(Integer.toString(listenPort.getPort()), getSingleChildElementTextContent(xml, PORT));
    assertTrue(getChildElementsTextContents(getSingleChildElement(xml, ENABLED_FEATURES), STRING_VALUE).containsAll(listenPort.getEnabledFeatures()));
    assertEquals(service.getId(), getSingleChildElement(xml, TARGET_SERVICE_REFERENCE).getAttribute(ATTRIBUTE_ID));
    assertEquals(tlsSettings.getClientAuthentication().getType(), getSingleChildElementTextContent(getSingleChildElement(xml, TLS_SETTINGS), CLIENT_AUTHENTICATION));
    assertEquals(privateKey.getId(), getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), PRIVATE_KEY_REFERENCE).getAttribute(ATTRIBUTE_ID));
    assertTrue(tlsSettings.getEnabledVersions().containsAll(getChildElementsTextContents(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_VERSIONS), STRING_VALUE)));
    assertTrue(tlsSettings.getEnabledCipherSuites().containsAll(getChildElementsTextContents(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), ENABLED_CIPHER_SUITES), STRING_VALUE)));
    assertPropertiesContent(tlsSettings.getProperties(), mapPropertiesElements(getSingleChildElement(getSingleChildElement(xml, TLS_SETTINGS), PROPERTIES), PROPERTIES));
    assertPropertiesContent(listenPort.getProperties(), mapPropertiesElements(getSingleChildElement(xml, PROPERTIES), PROPERTIES));
}