本文整理汇总了Java中org.mockito.internal.stubbing.answers.CallsRealMethods类的典型用法代码示例。如果您正苦于以下问题:Java CallsRealMethods类的具体用法?Java CallsRealMethods怎么用?Java CallsRealMethods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallsRealMethods类属于org.mockito.internal.stubbing.answers包,在下文中一共展示了CallsRealMethods类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUp
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Before
public void setUp() throws InterruptedException {
cache = Fakes.cache();
dm = mock(DistributionManager.class);
msg = mock(RemoteOperationMessage.class);
r = mock(LocalRegion.class);
txMgr = mock(TXManagerImpl.class);
tx = mock(TXStateProxyImpl.class);
when(msg.checkCacheClosing(dm)).thenReturn(false);
when(msg.checkDSClosing(dm)).thenReturn(false);
when(msg.getCache(dm)).thenReturn(cache);
when(msg.getRegionByPath(cache)).thenReturn(r);
when(msg.getTXManager(cache)).thenReturn(txMgr);
doAnswer(new CallsRealMethods()).when(msg).process(dm);
}
开发者ID:ampool,项目名称:monarch,代码行数:18,代码来源:RemoteOperationMessageTest.java
示例2: setUp
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Before
public void setUp() throws PRLocallyDestroyedException, InterruptedException {
cache = Fakes.cache();
dm = mock(DistributionManager.class);
msg = mock(PartitionMessage.class);
pr = mock(PartitionedRegion.class);
txMgr = mock(TXManagerImpl.class);
tx = mock(TXStateProxyImpl.class);
when(msg.checkCacheClosing(dm)).thenReturn(false);
when(msg.checkDSClosing(dm)).thenReturn(false);
when(msg.getPartitionedRegion()).thenReturn(pr);
when(msg.getGemFireCacheImpl()).thenReturn(cache);
when(msg.getStartPartitionMessageProcessingTime(pr)).thenReturn(startTime);
when(msg.getTXManagerImpl(cache)).thenReturn(txMgr);
doAnswer(new CallsRealMethods()).when(msg).process(dm);
}
开发者ID:ampool,项目名称:monarch,代码行数:19,代码来源:PartitionMessageTest.java
示例3: should_override_default_answer_for_spy_beans
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Test
public void should_override_default_answer_for_spy_beans() {
//given
final MockitoDoubleConfiguration configuration = configurationParser.parseSpyConfiguration(ANY_NAME, AnyTest.withAnswer());
//when
configuration.createMockSettings(mockSettings);
//then
final InOrder defaultAnswer = Mockito.inOrder(mockSettings);
defaultAnswer
.verify(mockSettings)
.defaultAnswer(argThat(HasDefaultAnswer.hasAnswerOfType(CallsRealMethods.class)));
defaultAnswer
.verify(mockSettings)
.defaultAnswer(argThat(HasDefaultAnswer.hasAnswerOfType(DoesNothing.class)));
}
开发者ID:pchudzik,项目名称:springmock,代码行数:19,代码来源:MockitoDoubleConfigurationParserTest.java
示例4: testFactory
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Test
public void testFactory() {
DBConnector collector=Mockito.mock(
DBConnector.class);
Table table=new Table();
table.setTableName("tst");
Mockito.when(collector.getAllTables()).thenReturn(Sets.newHashSet("tst"));
Mockito.when(collector.getTableMeta("tst")).thenReturn(table);
AbstractDataSourceProviderFactory factory = Mockito.mock(AbstractDataSourceProviderFactory.class,
new CallsRealMethods());
Mockito.doReturn(collector)
.when(factory)
.getDBCollector(Matchers.any(DataSourceConfiguration.class));
DataSourceConfiguration configuration = new DataSourceConfiguration(
DataSourceTypeEnum.DRUID, "testdb");
configuration.setEndPoint(Lists.newArrayList("http://test")); assertEquals(Lists.newArrayList(table),factory.create(configuration).getTables());
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:19,代码来源:AbstracDataSourceProviderFactoryTest.java
示例5: should_set_default_answer_for_spy_beans
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Test
public void should_set_default_answer_for_spy_beans() {
//given
final MockitoDoubleConfiguration configuration = configurationParser.parseSpyConfiguration(ANY_NAME, AnyTest.spy());
//when
configuration.createMockSettings(mockSettings);
//then
Mockito
.verify(mockSettings)
.defaultAnswer(argThat(HasDefaultAnswer.hasAnswerOfType(CallsRealMethods.class)));
}
开发者ID:pchudzik,项目名称:springmock,代码行数:14,代码来源:MockitoDoubleConfigurationParserTest.java
示例6: testParse
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testParse() {
String sql = "select count(clickcount_ag) as \"clickcount_ag\", testdim from tabletest group by testdim limit 100";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
TableDimension dimension = new TableDimension();
dimension.setName("testdim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testdim", dimension.getName());
assertEquals(0, dimension.getType());
TableDimension metric2 = new TableDimension();
metric2.setName("clickcount_ag");
metric2.setType(0);
metric2.setMultiValue(true);
List<TableDimension> metrics = new ArrayList<TableDimension>();
metrics.add(metric2);
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
table.setMetrics(metrics);
assertTrue(sqlTranslator.parseResultList(selectNode, table)
.getDimensions().contains("testdim"));
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:40,代码来源:SQLTranslatorTest.java
示例7: testInvalidAggregate
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testInvalidAggregate() {
String sql = "select count(*) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("countall");
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,true);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:36,代码来源:SQLTranslatorTest.java
示例8: testCountAll
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testCountAll() {
String sql = "select count(*) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count(*)");
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
assertEquals("countall",sqlTranslator.getAggregateKey(node, table,null,true));
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:33,代码来源:SQLTranslatorTest.java
示例9: testGetAggregate
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetAggregate() {
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
ColumnReference cNode=new ColumnReference();
TableName name=new TableName();
cNode.init("test",name);
Mockito.when(node.getOperand()).thenReturn(cNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,false);
} catch (SqlTranslationException ex) {
fail("unexpected SqlTranslationException");
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:41,代码来源:SQLTranslatorTest.java
示例10: testGetAggregateNumericConstantNode
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetAggregateNumericConstantNode() throws StandardException {
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
NumericConstantNode nNode=new NumericConstantNode();
Mockito.when(node.getOperand()).thenReturn(nNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,false);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:39,代码来源:SQLTranslatorTest.java
示例11: testGetAggregateNumericConstantNodeNot1
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetAggregateNumericConstantNodeNot1() throws StandardException {
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
NumericConstantNode nNode=new NumericConstantNode();
nNode.setValue(2);
Mockito.when(node.getOperand()).thenReturn(nNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,false);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:40,代码来源:SQLTranslatorTest.java
示例12: testGetAggregateNumericConstantNodeNotInt
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetAggregateNumericConstantNodeNotInt() throws StandardException {
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
NumericConstantNode nNode=new NumericConstantNode();
nNode.setValue("test");
Mockito.when(node.getOperand()).thenReturn(nNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,false);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:40,代码来源:SQLTranslatorTest.java
示例13: testGetUnsupportAggregate
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testGetUnsupportAggregate() throws StandardException {
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
Mockito.when(node.getOperand()).thenReturn(null);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
try {
sqlTranslator.getAggregateKey(node, table,null,false);
fail("expected SqlTranslationException");
} catch (SqlTranslationException ex) {
assertTrue(true);
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:39,代码来源:SQLTranslatorTest.java
示例14: testMultipleOutParameters
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@Test
public void testMultipleOutParameters() throws Exception {
URL fixtureURL = AbstractTypeUtilTest.class.getResource("MultipleOutParameters.fidl");
ModelLoader loader = new ModelLoader(fixtureURL.getPath());
Resource fixtureResource = loader.getResources().iterator().next();
class MyCallsRealMethods extends CallsRealMethods {
private static final long serialVersionUID = 1L;
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (invocation.getMethod().getName().equals("getTypeName")) {
Class<?> parameterType0 = invocation.getMethod().getParameterTypes()[0];
if (parameterType0.equals(FBasicTypeId.class)) {
return ((FBasicTypeId) invocation.getArguments()[0]).getName();
} else if (parameterType0.equals(FType.class)) {
return ((FType) invocation.getArguments()[0]).getName();
} else {
return super.answer(invocation);
}
} else {
return super.answer(invocation);
}
}
}
AbstractTypeUtil typeUtil = mock(AbstractTypeUtil.class, new MyCallsRealMethods());
Guice.createInjector().injectMembers(typeUtil);
FModel model = (FModel) fixtureResource.getContents().get(0);
String stringDatatype = FBasicTypeId.STRING.getName();
String numberDatatype = FBasicTypeId.INT16.getName();
String complexDatatype = model.getTypeCollections().get(0).getTypes().get(0).getName();
FMethod fixture = model.getInterfaces().get(0).getMethods().get(0);
Iterator<String> result = typeUtil.getTypeNamesForOutputParameter(fixture).iterator();
assertEquals(result.next(), stringDatatype);
assertEquals(result.next(), numberDatatype);
assertEquals(result.next(), complexDatatype);
assertFalse(result.hasNext());
}
开发者ID:bmwcarit,项目名称:joynr,代码行数:41,代码来源:AbstractTypeUtilTest.java
示例15: testParseCount
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testParseCount() {
String sql = "select count(distinct(testdim)) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
TableDimension dimension = new TableDimension();
dimension.setName("testdim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testdim", dimension.getName());
assertEquals(0, dimension.getType());
TableDimension metric = new TableDimension();
metric.setName("count");
metric.setType(0);
metric.setMultiValue(true);
TableDimension metric2 = new TableDimension();
metric2.setName("clickcount_ag");
metric2.setType(0);
metric2.setMultiValue(true);
List<TableDimension> metrics = new ArrayList<TableDimension>();
metrics.add(metric2);
metrics.add(metric);
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
table.setMetrics(metrics);
assertTrue(sqlTranslator.parseResultList(selectNode, table)
.getSimpleAggregateColsMap().containsKey("testdim"));
assertTrue(sqlTranslator.parseResultList(selectNode, table)
.getAggrKeyToAliasMap().containsValue("testdim"));
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:48,代码来源:SQLTranslatorTest.java
示例16: testParseBinary
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testParseBinary() {
String sql = "select testdim*2 as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
TableDimension dimension = new TableDimension();
dimension.setName("testdim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testdim", dimension.getName());
assertEquals(0, dimension.getType());
TableDimension metric = new TableDimension();
metric.setName("count");
metric.setType(0);
metric.setMultiValue(true);
TableDimension metric2 = new TableDimension();
metric2.setName("clickcount_ag");
metric2.setType(0);
metric2.setMultiValue(true);
List<TableDimension> metrics = new ArrayList<TableDimension>();
metrics.add(metric2);
metrics.add(metric);
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
table.setMetrics(metrics);
assertTrue(sqlTranslator.parseResultList(selectNode, table)
.getAggrKeyToAliasMap().containsValue("testdim"));
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:46,代码来源:SQLTranslatorTest.java
示例17: testParseOderBy
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testParseOderBy() {
String sql = "select count(1) as testdim from tabletest where (site=0 or not(region='11')) order by testdim";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
QueryDescription queryDesc = sqlTranslator.parse(sql);
SelectNode selectNode = queryDesc.getSelectNode();
TableDimension dimension = new TableDimension();
dimension.setName("testdim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testdim", dimension.getName());
assertEquals(0, dimension.getType());
TableDimension metric = new TableDimension();
metric.setName("count");
metric.setType(0);
metric.setMultiValue(true);
TableDimension metric2 = new TableDimension();
metric2.setName("clickcount_ag");
metric2.setType(0);
metric2.setMultiValue(true);
List<TableDimension> metrics = new ArrayList<TableDimension>();
metrics.add(metric2);
metrics.add(metric);
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
table.setMetrics(metrics);
assertTrue(sqlTranslator.parseResultList(selectNode, table)
.getAggrKeyToAliasMap().containsValue("testdim"));
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:47,代码来源:SQLTranslatorTest.java
示例18: testAddCompositeAggregateNode
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testAddCompositeAggregateNode() throws StandardException{
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
AggregateNode node =Mockito.mock(AggregateNode.class);
Mockito.when(node.getAggregateName()).thenReturn("count");
Mockito.when(node.isDistinct()).thenReturn(true);
NumericConstantNode nNode=new NumericConstantNode();
nNode.setValue(1);
Mockito.when(node.getOperand()).thenReturn(nNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
Map<String, AggregateNode> aggregateNodesMap =new HashMap<String, AggregateNode>();
aggregateNodesMap.put("count", node);
Map<String, String> aggrKeyToAliasMap =new HashMap<String, String>();
try {
sqlTranslator.addCompositeAggregateNode(node,aggregateNodesMap, aggrKeyToAliasMap, null, table,false);
} catch (SqlTranslationException ex) {
assertTrue(false);
fail("unexpected SqlTranslationException");
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:46,代码来源:SQLTranslatorTest.java
示例19: testAddCompositeAggregateNodeOperatorNode
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testAddCompositeAggregateNodeOperatorNode() throws StandardException{
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
BinaryArithmeticOperatorNode node =Mockito.mock(BinaryArithmeticOperatorNode.class);
NumericConstantNode nNode=new NumericConstantNode();
nNode.setValue(1);
NumericConstantNode rNode=new NumericConstantNode();
rNode.setValue(1);
Mockito.when(node.getLeftOperand()).thenReturn(nNode);
Mockito.when(node.getRightOperand()).thenReturn(rNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
Map<String, AggregateNode> aggregateNodesMap =new HashMap<String, AggregateNode>();
aggregateNodesMap.put("count", new AggregateNode());
Map<String, String> aggrKeyToAliasMap =new HashMap<String, String>();
try {
sqlTranslator.addCompositeAggregateNode(node,aggregateNodesMap, aggrKeyToAliasMap, null, table,false);
} catch (SqlTranslationException ex) {
assertTrue(false);
fail("unexpected SqlTranslationException");
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:50,代码来源:SQLTranslatorTest.java
示例20: testAddCompositeAggregateNodeOperatorNodeLeft
import org.mockito.internal.stubbing.answers.CallsRealMethods; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testAddCompositeAggregateNodeOperatorNodeLeft() throws StandardException{
String sql = "select count(testdim) as testdim from tabletest where (site=0 or not(region='11')) order by notexist";
SQLTranslator sqlTranslator = Mockito.mock(SQLTranslator.class,
new CallsRealMethods());
Mockito.doReturn("")
.when(sqlTranslator)
.checkNameChange(Mockito.any(ColumnReference.class),
Mockito.any(Table.class), Mockito.any(Map.class));
assertEquals("tabletest", sqlTranslator.getTableName(sql));
sqlTranslator.parse(sql);
BinaryArithmeticOperatorNode node =Mockito.mock(BinaryArithmeticOperatorNode.class);
ColumnReference nNode= Mockito.mock(ColumnReference.class);
Mockito.when(nNode.getColumnName()).thenReturn("testdim");
NumericConstantNode rNode=new NumericConstantNode();
rNode.setValue(1);
Mockito.when(node.getLeftOperand()).thenReturn(nNode);
Mockito.when(node.getRightOperand()).thenReturn(nNode);
TableDimension dimension = new TableDimension();
dimension.setName("testDim");
dimension.setType(0);
dimension.setMultiValue(true);
assertEquals("testDim", dimension.getName());
assertEquals(0, dimension.getType());
Table table = new Table();
table.setTableName("tabletest");
table.setNoInnerJoin(false);
table.setDateColumn("testDate");
table.setDimensions(Lists.newArrayList(dimension));
Map<String, AggregateNode> aggregateNodesMap =new HashMap<String, AggregateNode>();
aggregateNodesMap.put("count", new AggregateNode());
Map<String, String> aggrKeyToAliasMap =new HashMap<String, String>();
try {
sqlTranslator.addCompositeAggregateNode(node,aggregateNodesMap, aggrKeyToAliasMap, null, table,false);
} catch (SqlTranslationException ex) {
assertTrue(false);
fail("unexpected SqlTranslationException");
}
}
开发者ID:pulsarIO,项目名称:pulsar-reporting-api,代码行数:50,代码来源:SQLTranslatorTest.java
注:本文中的org.mockito.internal.stubbing.answers.CallsRealMethods类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论