DiskStoreCommandsUtils { static boolean diskStoreBeanAndMemberBeanDiskStoreExists(DistributedSystemMXBean dsMXBean, String memberName, String diskStore) { return diskStoreBeanExists(dsMXBean, memberName, diskStore) && memberBeanDiskStoreExists(dsMXBean, memberName, diskStore); }    }
@Test public void diskStoreBeanAndMemberBeanDiskStoreExists() throws Exception { Map<String, String[]> memberDiskStore = new HashMap<>(); memberDiskStore.put(memberName, new String[] {diskStoreName}); ObjectName objectName = new ObjectName(""); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(memberDiskStore).when(distributedSystemMXBean).listMemberDiskstore(); doReturn(objectName).when(distributedSystemMXBean).fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isTrue(); }
@Test public void diskStoreBeanExistsAndMemberDiskStoreNotFound() throws Exception { Map<String, String[]> memberDiskStore = new HashMap<>(); memberDiskStore.put(memberName, new String[] {}); ObjectName objectName = new ObjectName(""); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(memberDiskStore).when(distributedSystemMXBean).listMemberDiskstore(); doReturn(objectName).when(distributedSystemMXBean).fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isFalse(); }
@Test public void diskStoreBeanNotFoundAndMemberDiskStoreExists() throws Exception { Map<String, String[]> memberDiskStore = new HashMap<>(); memberDiskStore.put(memberName, new String[] {diskStoreName}); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(memberDiskStore).when(distributedSystemMXBean).listMemberDiskstore(); doThrow(new Exception("not found")).when(distributedSystemMXBean) .fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isFalse(); }
@Test public void diskStoreBeanExistsMemberDiskStoreIsNull() throws Exception { ObjectName objectName = new ObjectName(""); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(null).when(distributedSystemMXBean).listMemberDiskstore(); doReturn(objectName).when(distributedSystemMXBean).fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isFalse(); }
@Test public void diskStoreBeanExistsMemberDiskStoreContainsNullArray() throws Exception { Map<String, String[]> memberDiskStore = new HashMap<>(); memberDiskStore.put(memberName, null); ObjectName objectName = new ObjectName(""); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(memberDiskStore).when(distributedSystemMXBean).listMemberDiskstore(); doReturn(objectName).when(distributedSystemMXBean).fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isFalse(); }
@Test public void diskStoreBeanExistsMemberDiskStoreNamesHasNullValues() throws Exception { Map<String, String[]> memberDiskStore = new HashMap<>(); memberDiskStore.put(memberName, new String[] {null, null}); ObjectName objectName = new ObjectName(""); DistributedSystemMXBean distributedSystemMXBean = Mockito.mock(DistributedSystemMXBean.class); doReturn(memberDiskStore).when(distributedSystemMXBean).listMemberDiskstore(); doReturn(objectName).when(distributedSystemMXBean).fetchDiskStoreObjectName(any(), any()); assertThat( DiskStoreCommandsUtils.diskStoreBeanAndMemberBeanDiskStoreExists(distributedSystemMXBean, memberName, diskStoreName)).isFalse(); }