private void buildSelectContext(final boolean orderByIsNull, final boolean selectFieldsIsNull,
final boolean filterIsNull, final boolean isTopNull, final boolean isSkipNull) {
builder = null;
selectContext = null;
keyPredicates = new ArrayList<KeyPredicate>();
GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
EdmEntitySet entitySet = EasyMock.createMock(EdmEntitySet.class);
EdmEntityType entityType = EasyMock.createMock(EdmEntityType.class);
KeyPredicate keyPredicate = EasyMock.createMock(KeyPredicate.class);
EdmProperty kpProperty = EasyMock.createMock(EdmProperty.class);
EdmType edmType1 = EasyMock.createMock(EdmType.class);
EdmMapping mapping = EasyMock.createMock(EdmMapping.class);
EasyMock.expect(keyPredicate.getLiteral()).andStubReturn("1");
try {
EasyMock.expect(mapping.getInternalName()).andStubReturn("Field1");
EasyMock.expect(kpProperty.getMapping()).andStubReturn(mapping);
EasyMock.expect(kpProperty.getType()).andStubReturn(edmType1);
} catch (EdmException e2) {
fail("this should not happen");
}
EasyMock.expect(keyPredicate.getProperty()).andStubReturn(kpProperty);
EasyMock.replay(mapping, edmType1, kpProperty, keyPredicate);
keyPredicates.add(keyPredicate);
int i = 0;
List<OrderExpression> orderList = new ArrayList<OrderExpression>(2);
do {
EdmType edmType = EasyMock.createMock(EdmType.class);
try {
EasyMock.expect(edmType.getName()).andStubReturn(fields[i]);
EasyMock.replay(edmType);
} catch (EdmException e2) {
fail("Exception not Expected");
}
PropertyExpression commonExpression = EasyMock.createMock(PropertyExpression.class);
EasyMock.expect(commonExpression.getEdmType()).andStubReturn(edmType);
EdmProperty edmTyped = EasyMock.createMock(EdmProperty.class);
EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
try {
EasyMock.expect(edmTyped.getMapping()).andStubReturn(edmMapping);
} catch (EdmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
EasyMock.expect(commonExpression.getEdmProperty()).andStubReturn(edmTyped);
OrderExpression order = EasyMock.createMock(OrderExpression.class);
EasyMock.expect(order.getExpression()).andStubReturn(commonExpression);
EasyMock.expect(order.getSortOrder()).andStubReturn(orderType[i]);
EasyMock.replay(edmMapping, edmTyped, commonExpression);
EasyMock.replay(order);
orderList.add(order);
} while (++i < 2);
OrderByExpression orderBy = EasyMock.createMock(OrderByExpression.class);
EasyMock.expect(orderBy.getOrders()).andStubReturn(orderList);
EasyMock.replay(orderBy);
try {
i = 0;
List<SelectItem> selectItemList = new ArrayList<SelectItem>(2);
do {
EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
EasyMock.expect(edmMapping.getInternalName()).andStubReturn(fields[i]);
EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class);
EasyMock.expect(edmProperty.getMapping()).andStubReturn(edmMapping);
EasyMock.replay(edmMapping, edmProperty);
SelectItem selectItem = EasyMock.createMock(SelectItem.class);
EasyMock.expect(selectItem.getProperty()).andStubReturn(edmProperty);
EasyMock.replay(selectItem);
selectItemList.add(selectItem);
} while (++i < 2);
EasyMock.expect(entityType.getMapping()).andStubReturn(null);
EasyMock.expect(entityType.getName()).andStubReturn(entityTypeName);
EasyMock.expect(entityType.getKeyProperties()).andStubReturn(getLocalKeyProperties());
EasyMock.replay(entityType);
EasyMock.expect(entitySet.getEntityType()).andStubReturn(entityType);
EasyMock.replay(entitySet);
EasyMock.expect(resultsView.getTargetEntitySet()).andStubReturn(entitySet);
if (orderByIsNull) {
EasyMock.expect(resultsView.getOrderBy()).andStubReturn(null);
} else {
EasyMock.expect(resultsView.getOrderBy()).andStubReturn(orderBy);
}
if (selectFieldsIsNull) {
EasyMock.expect(resultsView.getSelect()).andStubReturn(null);
} else {
EasyMock.expect(resultsView.getSelect()).andStubReturn(selectItemList);
}
// FilterExpression filterExpression =
// EasyMock.createMock(FilterExpression.class);
// EasyMock.expect(filterExpression.g)
if (filterIsNull) {
EasyMock.expect(resultsView.getFilter()).andStubReturn(null);
} else {
EasyMock.expect(resultsView.getFilter()).andStubReturn(
getFilterExpressionMockedObj(ExpressionKind.PROPERTY, "SalesOrder"));
}
if (isTopNull) {
EasyMock.expect(resultsView.getTop()).andStubReturn(null);
} else {
EasyMock.expect(resultsView.getTop()).andStubReturn(10);
}
if (isSkipNull) {
EasyMock.expect(resultsView.getSkip()).andStubReturn(null);
} else {
EasyMock.expect(resultsView.getSkip()).andStubReturn(0);
}
EasyMock.expect(resultsView.getKeyPredicates()).andStubReturn(keyPredicates);
EasyMock.replay(resultsView);
} catch (EdmException e1) {
fail("Exception not Expected");
}