public void add(final Portal portal) throws SQLException {
        boolean isNamedPortal = !portal.getName().isEmpty();
        Preconditions.checkState(!isNamedPortal || !portals.containsKey(portal.getName()), "Named portal `%s` must be explicitly closed", portal.getName());
        Portal previousPortal = portals.put(portal.getName(), portal);
        if (null != previousPortal) {
            previousPortal.close();
        }
    }
@Test
    void assertAddDuplicateNamedPortal() throws SQLException {
        Portal portal = mock(Portal.class);
        when(portal.getName()).thenReturn("P_1");
        portalContext.add(portal);
        assertThrows(IllegalStateException.class, () -> portalContext.add(portal));
    }