use of junitparams.Parameters in project druid by druid-io.
the class WhiteListBasedDruidToTimelineEventConverterTest method testGetName.
@Test
@Parameters
public void testGetName(ServiceMetricEvent serviceMetricEvent, String expectedPath) {
TimelineMetric metric = defaultWhiteListBasedDruidToTimelineEventConverter.druidEventToTimelineMetric(serviceMetricEvent);
String path = null;
if (metric != null) {
path = metric.getMetricName();
}
Assert.assertEquals(expectedPath, path);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method verifySearchIndexPermissions.
@Test
@Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
public void verifySearchIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
// Create index and region
createIndexAndRegion();
// Connect gfsh
this.gfshShell.secureConnectAndVerify(this.locator.getPort(), GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
// Attempt to search lucene index
CommandResult result = this.gfshShell.executeCommand(getSearchIndexCommand());
// Verify result
verifyResult(user, result);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method verifyDestroyIndexPermissions.
@Test
@Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
public void verifyDestroyIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
// Create index and region
createIndexAndRegion();
// Connect gfsh
this.gfshShell.secureConnectAndVerify(this.locator.getPort(), GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
// Attempt to search lucene index
CommandResult result = this.gfshShell.executeCommand(getDestroyIndexCommand());
// Verify result
verifyResult(user, result);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testDestroySingleIndexNoRegionMembers.
@Test
@Parameters({ "true", "false" })
public void testDestroySingleIndexNoRegionMembers(boolean expectedToSucceed) throws Exception {
LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
String indexName = "index";
String regionPath = "regionPath";
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1, new Object[] { indexName, regionPath });
cliFunctionResults.add(new CliFunctionResult("member0"));
} else {
Exception e = new IllegalStateException("failed");
expectedStatus = e.getMessage();
cliFunctionResults.add(new CliFunctionResult("member0", e, e.getMessage()));
}
doReturn(mockResultCollector).when(commands).executeFunction(isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
doReturn(cliFunctionResults).when(mockResultCollector).getResult();
doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());
doReturn(Collections.emptySet()).when(commands).getRegionMembers(any(), any());
CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
verifyDestroyIndexCommandResult(result, cliFunctionResults, expectedStatus);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testDestroySingleIndexWithRegionMembers.
@Test
@Parameters({ "true", "false" })
public void testDestroySingleIndexWithRegionMembers(boolean expectedToSucceed) throws Exception {
LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
String indexName = "index";
String regionPath = "regionPath";
Set<DistributedMember> members = new HashSet<>();
DistributedMember mockMember = mock(DistributedMember.class);
when(mockMember.getId()).thenReturn("member0");
members.add(mockMember);
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1, new Object[] { indexName, regionPath });
cliFunctionResults.add(new CliFunctionResult(mockMember.getId()));
} else {
Exception e = new IllegalStateException("failed");
expectedStatus = e.getMessage();
cliFunctionResults.add(new CliFunctionResult("member0", e, e.getMessage()));
}
doReturn(mockResultCollector).when(commands).executeFunction(isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
doReturn(cliFunctionResults).when(mockResultCollector).getResult();
doReturn(members).when(commands).getNormalMembers(any());
doReturn(members).when(commands).getRegionMembers(any(), any());
CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
verifyDestroyIndexCommandResult(result, cliFunctionResults, expectedStatus);
}
Aggregations