Package com.sonyericsson.hudson.plugins.gerrit.trigger

Examples of com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer


     */
    @Test
    public void testSnapshotVersion() {
        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = PowerMockito.mock(PluginImpl.class);
        GerritServer server = mock(GerritServer.class);
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);
        PowerMockito.when(plugin.getServer(testServer)).thenReturn(server);
        String version = "2.2.2.1-340-g47084d4";
        PowerMockito.when(server.getGerritVersion()).thenReturn(version);
        assertTrue(GerritVersionChecker.isCorrectVersion(GerritVersionChecker.Feature.fileTrigger , testServer));
        assertTrue(GerritVersionNumber.getGerritVersionNumber(version).isSnapshot());
    }
View Full Code Here


     * Test triggering job with events using API.
     * @throws Exception Error creating job.
     */
    @Test
    public void testApiTriggerBuild() throws Exception {
        GerritServer gerritServer = new GerritServer(gerritServerName);
        PluginImpl.getInstance().addServer(gerritServer);
        gerritServer.start();
        FreeStyleProject project = DuplicatesUtil.createGerritTriggeredJob(j, projectName, gerritServerName);

        GerritTriggerApi api = new GerritTriggerApi();
        Handler handler = null;
        try {
View Full Code Here

     * @see GerritTriggeredEvent#getProvider()
     */
    private IGerritHudsonTriggerConfig getServerConfig(GerritTriggeredEvent event) {
        Provider provider = event.getProvider();
        if (provider != null) {
            GerritServer gerritServer = PluginImpl.getInstance().getServer(provider.getName());
            if (gerritServer != null) {
                return gerritServer.getConfig();
            } else {
                logger.warn("Could not find server config for {} - no such server.", provider.getName());
            }
        } else {
            logger.warn("The event {} has no provider specified. BUG!", event);
View Full Code Here

     * @return list of GerritSlave (can be empty but never null)
     */
    public List<GerritSlave> gerritSlavesToWaitFor(String gerritServerName) {
        List<GerritSlave> gerritSlaves = new ArrayList<GerritSlave>();

        GerritServer gerritServer = PluginImpl.getInstance().getServer(gerritServerName);
        if (gerritServer == null) {
            logger.warn("Could not find server: {}", serverName);
            return gerritSlaves;
        }

        ReplicationConfig replicationConfig = gerritServer.getConfig().getReplicationConfig();
        if (replicationConfig != null && replicationConfig.isEnableReplication()) {
            if (replicationConfig.isEnableSlaveSelectionInJobs()) {
                GerritSlave gerritSlave = replicationConfig.getGerritSlave(gerritSlaveId, true);
                if (gerritSlave != null) {
                    gerritSlaves.add(gerritSlave);
View Full Code Here

    public void testGetGerritUrlJsonNoUrl() {
        JSONObject change = new JSONObject();
        change.put("number", "100");
        PowerMockito.mockStatic(PluginImpl.class);
        PluginImpl plugin = mock(PluginImpl.class);
        GerritServer server = mock(GerritServer.class);
        when(plugin.getServer(any(String.class))).thenReturn(server);
        when(server.getConfig()).thenReturn(Setup.createConfig());
        PowerMockito.when(PluginImpl.getInstance()).thenReturn(plugin);

        ManualTriggerAction action = new ManualTriggerAction();
        String url = action.getGerritUrl(change, null);
View Full Code Here

            ListBoxModel items = new ListBoxModel();
            if (ANY_SERVER.equals(serverName)) {
                items.add(Messages.SlaveSelectionNotAllowedAnyServer(Messages.AnyServer()), "");
                return items;
            }
            GerritServer server = PluginImpl.getInstance().getServer(serverName);
            if (server == null) {
                logger.warn(Messages.CouldNotFindServer(serverName));
                items.add(Messages.CouldNotFindServer(serverName), "");
                return items;
            }
            ReplicationConfig replicationConfig = server.getConfig().getReplicationConfig();
            if (replicationConfig == null) {
                items.add(Messages.ReplicationNotConfigured(), "");
                return items;
            } else if (!replicationConfig.isEnableReplication()) {
                items.add(Messages.ReplicationNotConfigured(), "");
View Full Code Here

        if (provider == null) {
            provider = new Provider();
            provider.setName(PluginImpl.DEFAULT_SERVER_NAME);
            tEvent.setProvider(provider);
        }
        GerritServer server = PluginImpl.getInstance().getServer(provider.getName());
        //TODO: investigate the case where server == null:
        if (server != null) {
            return server.getConfig().getGerritFrontEndUrlFor(tEvent);
        } else {
            return "";
        }
    }
View Full Code Here

    /**
     * Add this patches listener to the GerritServer object to which it is associated.
     */
    private void addThisAsListener() {
        GerritServer server = PluginImpl.getInstance().getServer(serverName);
        if (server != null) {
            server.addListener(this);
        } else {
            logger.error("Could not find server {}", serverName);
        }
    }
View Full Code Here

    /**
     * Shutdown the listener.
     */
    public void shutdown() {
        GerritServer server = PluginImpl.getInstance().getServer(serverName);
        if (server != null) {
            server.removeListener(this);
        } else {
            logger.error("Could not find server {}", serverName);
        }
    }
View Full Code Here

    /**
     * Get the server config.
     * @return the server config or null if not found.
     */
    private IGerritHudsonTriggerConfig getConfig() {
        GerritServer server = PluginImpl.getInstance().getServer(serverName);
        if (server != null) {
            IGerritHudsonTriggerConfig config = server.getConfig();
            if (config != null) {
                return config;
            } else {
                logger.error("Could not find the config for server {}", serverName);
            }
View Full Code Here

TOP

Related Classes of com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.