Package org.netmelody.cieye.spies.jenkins

Source Code of org.netmelody.cieye.spies.jenkins.JenkinsObservationAgency

package org.netmelody.cieye.spies.jenkins;

import java.text.SimpleDateFormat;

import org.netmelody.cieye.core.domain.CiServerType;
import org.netmelody.cieye.core.domain.Feature;
import org.netmelody.cieye.core.observation.CiSpy;
import org.netmelody.cieye.core.observation.CodeBook;
import org.netmelody.cieye.core.observation.CommunicationNetwork;
import org.netmelody.cieye.core.observation.KnownOffendersDirectory;
import org.netmelody.cieye.core.observation.ObservationAgency;

public final class JenkinsObservationAgency implements ObservationAgency {

    @Override
    public CiSpy provideSpyFor(Feature feature, CommunicationNetwork network, KnownOffendersDirectory directory) {
        final CodeBook codeBook = new CodeBook(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"))
                                      .withCredentials(feature.username(), feature.password());
        return new JenkinsSpy(feature.endpoint(), directory, network.makeContact(codeBook));
    }

    @Override
    public boolean canProvideSpyFor(CiServerType type) {
        return "JENKINS".equals(type.name()) || "HUDSON".equals(type.name());
    }
}
TOP

Related Classes of org.netmelody.cieye.spies.jenkins.JenkinsObservationAgency

TOP
Copyright © 2018 www.massapi.com. 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.