Search in sources :

Example 1 with PulseConfig

use of org.apache.geode.tools.pulse.internal.data.PulseConfig in project geode by apache.

the class PulseControllerJUnitTest method setup.

@Before
public void setup() throws Exception {
    this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    cluster = Mockito.spy(Cluster.class);
    Cluster.Region region = new Cluster.Region();
    region.setName(REGION_NAME);
    region.setFullPath(REGION_PATH);
    region.setRegionType(REGION_TYPE);
    region.setMemberCount(1);
    region.setMemberName(new ArrayList<String>() {

        {
            add(MEMBER_NAME);
        }
    });
    region.setPutsRate(12.31D);
    region.setGetsRate(27.99D);
    Cluster.RegionOnMember regionOnMember = new Cluster.RegionOnMember();
    regionOnMember.setRegionFullPath(REGION_PATH);
    regionOnMember.setMemberName(MEMBER_NAME);
    region.setRegionOnMembers(new ArrayList<Cluster.RegionOnMember>() {

        {
            add(regionOnMember);
        }
    });
    cluster.addClusterRegion(REGION_PATH, region);
    Cluster.Member member = new Cluster.Member();
    member.setId(MEMBER_ID);
    member.setName(MEMBER_NAME);
    member.setUptime(1L);
    member.setHost(PHYSICAL_HOST_NAME);
    member.setGemfireVersion(GEMFIRE_VERSION);
    member.setCpuUsage(55.77123D);
    member.setMemberRegions(new HashMap<String, Cluster.Region>() {

        {
            put(REGION_NAME, region);
        }
    });
    Cluster.AsyncEventQueue aeq = new Cluster.AsyncEventQueue();
    aeq.setAsyncEventListener(AEQ_LISTENER);
    member.setAsyncEventQueueList(new ArrayList() {

        {
            add(aeq);
        }
    });
    Cluster.Client client = new Cluster.Client();
    client.setId("100");
    client.setName(CLIENT_NAME);
    client.setUptime(1L);
    member.setMemberClientsHMap(new HashMap<String, Cluster.Client>() {

        {
            put(CLIENT_NAME, client);
        }
    });
    cluster.setMembersHMap(new HashMap() {

        {
            put(MEMBER_NAME, member);
        }
    });
    cluster.setPhysicalToMember(new HashMap() {

        {
            put(PHYSICAL_HOST_NAME, new ArrayList() {

                {
                    add(member);
                }
            });
        }
    });
    cluster.setServerName(CLUSTER_NAME);
    cluster.setMemoryUsageTrend(new CircularFifoBuffer() {

        {
            add(1);
            add(2);
            add(3);
        }
    });
    cluster.setWritePerSecTrend(new CircularFifoBuffer() {

        {
            add(1.29);
            add(2.3);
            add(3.0);
        }
    });
    cluster.setThroughoutReadsTrend(new CircularFifoBuffer() {

        {
            add(1);
            add(2);
            add(3);
        }
    });
    cluster.setThroughoutWritesTrend(new CircularFifoBuffer() {

        {
            add(4);
            add(5);
            add(6);
        }
    });
    Repository repo = Mockito.spy(Repository.class);
    // Set up a partial mock for some static methods
    spy(Repository.class);
    when(Repository.class, "get").thenReturn(repo);
    doReturn(cluster).when(repo).getCluster();
    PulseConfig config = new PulseConfig();
    File tempQueryLog = tempFolder.newFile("query_history.log");
    config.setQueryHistoryFileName(tempQueryLog.toString());
    doReturn(config).when(repo).getPulseConfig();
    PulseController.pulseVersion.setPulseVersion("not empty");
    PulseController.pulseVersion.setPulseBuildId("not empty");
    PulseController.pulseVersion.setPulseBuildDate("not empty");
    PulseController.pulseVersion.setPulseSourceDate("not empty");
    PulseController.pulseVersion.setPulseSourceRevision("not empty");
    PulseController.pulseVersion.setPulseSourceRepository("not empty");
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) Matchers.anyString(org.mockito.Matchers.anyString) CircularFifoBuffer(org.apache.commons.collections.buffer.CircularFifoBuffer) Repository(org.apache.geode.tools.pulse.internal.data.Repository) PulseConfig(org.apache.geode.tools.pulse.internal.data.PulseConfig) File(java.io.File) Before(org.junit.Before)

Aggregations

File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CircularFifoBuffer (org.apache.commons.collections.buffer.CircularFifoBuffer)1 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)1 PulseConfig (org.apache.geode.tools.pulse.internal.data.PulseConfig)1 Repository (org.apache.geode.tools.pulse.internal.data.Repository)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1