@Override
    public GatewayTestResultBean test(NewGatewayBean gatewayToTest) throws NotAuthorizedException {
        securityContext.checkAdminPermissions();

        GatewayTestResultBean rval = new GatewayTestResultBean();

        try {
            GatewayBean testGateway = new GatewayBean();
            testGateway.setName(gatewayToTest.getName());
            testGateway.setType(gatewayToTest.getType());
            testGateway.setConfiguration(gatewayToTest.getConfiguration());
            IGatewayLink gatewayLink = gatewayLinkFactory.create(testGateway);
            SystemStatus status = gatewayLink.getStatus();
            String detail = MAPPER.writer().writeValueAsString(status);
            rval.setSuccess(true);
            rval.setDetail(detail);
        } catch (GatewayAuthenticationException e) {
            rval.setSuccess(false);
            rval.setDetail(Messages.i18n.format("GatewayResourceImpl.AuthenticationFailed")); //$NON-NLS-1$
        } catch (Exception e) {
            rval.setSuccess(false);
            rval.setDetail(e.getMessage());
        }

        return rval;
    }
@see IGatewayResource#test(io.apiman.manager.api.beans.gateways.NewGatewayBean)
manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/GatewayResourceImpl.java