Search in sources :

Example 1 with GridProfile

use of org.apache.geode.internal.cache.GridAdvisor.GridProfile in project geode by apache.

the class GridProfileTest method shouldBeMockable.

@Test
public void shouldBeMockable() throws Exception {
    GridProfile mockGridProfile = mock(GridProfile.class);
    ProfileId mockProfileId = mock(ProfileId.class);
    List<Profile> listOfProfiles = new ArrayList<>();
    listOfProfiles.add(mock(Profile.class));
    when(mockGridProfile.getHost()).thenReturn("HOST");
    when(mockGridProfile.getPort()).thenReturn(1);
    when(mockGridProfile.getId()).thenReturn(mockProfileId);
    mockGridProfile.setHost("host");
    mockGridProfile.setPort(2);
    mockGridProfile.tellLocalControllers(true, true, listOfProfiles);
    mockGridProfile.tellLocalBridgeServers(true, true, listOfProfiles);
    verify(mockGridProfile, times(1)).setHost("host");
    verify(mockGridProfile, times(1)).setPort(2);
    verify(mockGridProfile, times(1)).tellLocalControllers(true, true, listOfProfiles);
    verify(mockGridProfile, times(1)).tellLocalBridgeServers(true, true, listOfProfiles);
    assertThat(mockGridProfile.getHost()).isEqualTo("HOST");
    assertThat(mockGridProfile.getPort()).isEqualTo(1);
    assertThat(mockGridProfile.getId()).isSameAs(mockProfileId);
}
Also used : ProfileId(org.apache.geode.distributed.internal.DistributionAdvisor.ProfileId) GridProfile(org.apache.geode.internal.cache.GridAdvisor.GridProfile) ArrayList(java.util.ArrayList) Profile(org.apache.geode.distributed.internal.DistributionAdvisor.Profile) GridProfile(org.apache.geode.internal.cache.GridAdvisor.GridProfile) Test(org.junit.Test) UnitTest(org.apache.geode.test.junit.categories.UnitTest)

Aggregations

ArrayList (java.util.ArrayList)1 Profile (org.apache.geode.distributed.internal.DistributionAdvisor.Profile)1 ProfileId (org.apache.geode.distributed.internal.DistributionAdvisor.ProfileId)1 GridProfile (org.apache.geode.internal.cache.GridAdvisor.GridProfile)1 UnitTest (org.apache.geode.test.junit.categories.UnitTest)1 Test (org.junit.Test)1