public static List<SqlExpectation> buildSqlExpectationList( SqlExpectations expectations, SqlExpectation expectation, NoSql notAllowedQueries) { List<SqlExpectation> expectationList = new ArrayList<SqlExpectation>(); if (null != expectation && null != notAllowedQueries) { throw new IllegalArgumentException("Cannot specify @Expectation and @NotAllowedQueries on one test method"); } else if (null != expectations && null != notAllowedQueries) { throw new IllegalArgumentException("Cannot specify @Expectations and @NotAllowedQueries on one test method"); } else if (null != expectations || null != expectation) { if (null != expectation) { expectationList.add(expectation); } if (null != expectations) { expectationList.addAll(Arrays.asList(expectations.value())); } for (SqlExpectation expectation1 : expectationList) { Range.parse(expectation1.count()); Range.parse(expectation1.rows()); } } else if (null != notAllowedQueries) { SqlExpectation annotation = NoSql.class.getAnnotation(SqlExpectation.class); expectationList.add(annotation); } return expectationList; }
@Test(expected = IllegalArgumentException.class) public void testAmbiguousConfiguration2() { new Range(-1,4,3); }
public static List<SocketExpectation> buildSocketExpectationList( SocketExpectation socketExpectation, SocketExpectations socketExpectations, NoSocketsAllowed noSocketsAllowed) { List<SocketExpectation> socketExpectationList = new ArrayList<SocketExpectation>(); if (null != socketExpectation && null != noSocketsAllowed) { throw new IllegalArgumentException("Cannot specify @Expectation and @NotAllowedQueries on one test method"); } else if (null != socketExpectations && null != noSocketsAllowed) { throw new IllegalArgumentException("Cannot specify @Expectations and @NotAllowedQueries on one test method"); } else if (null != socketExpectations || null != socketExpectation) { if (null != socketExpectation) { socketExpectationList.add(socketExpectation); } if (null != socketExpectations) { socketExpectationList.addAll(Arrays.asList(socketExpectations.value())); } for (SocketExpectation expectation1 : socketExpectationList) { Range.parse(expectation1.connections()); } } else if (null != noSocketsAllowed) { SocketExpectation annotation = NoSocketsAllowed.class.getAnnotation(SocketExpectation.class); socketExpectationList.add(annotation); } return socketExpectationList; }
public static Range parse(Count count) { return new Range(count.value(), count.min(), count.max()); }
for (SqlExpectation sqlExpectation : sqlExpectationList) { spy = spy.expect(new SqlQueries.SqlExpectation( Range.parse(sqlExpectation.count()).min, Range.parse(sqlExpectation.count()).max, Range.parse(sqlExpectation.rows()).min, Range.parse(sqlExpectation.rows()).max, sqlExpectation.threads(), sqlExpectation.query() for (SocketExpectation socketExpectation : socketExpectationList) { spy = spy.expect(new TcpConnections.TcpExpectation( Range.parse(socketExpectation.connections()).min, Range.parse(socketExpectation.connections()).max, socketExpectation.threads(), "".equals(socketExpectation.hostName()) ? null : socketExpectation.hostName()
@Test(expected = IllegalArgumentException.class) public void testAmbiguousConfiguration1() { new Range(1,2,3); }
for (SqlExpectation sqlExpectation : sqlExpectationList) { spy = spy.expect(new SqlQueries.SqlExpectation( Range.parse(sqlExpectation.count()).min, Range.parse(sqlExpectation.count()).max, Range.parse(sqlExpectation.rows()).min, Range.parse(sqlExpectation.rows()).max, sqlExpectation.threads(), sqlExpectation.query() for (SocketExpectation socketExpectation : socketExpectationList) { spy = spy.expect(new TcpConnections.TcpExpectation( Range.parse(socketExpectation.connections()).min, Range.parse(socketExpectation.connections()).max, socketExpectation.threads(), "".equals(socketExpectation.hostName()) ? null : socketExpectation.hostName()
for (SqlExpectation sqlExpectation : sqlExpectationList) { spy = spy.expect(new SqlQueries.SqlExpectation( Range.parse(sqlExpectation.count()).min, Range.parse(sqlExpectation.count()).max, Range.parse(sqlExpectation.rows()).min, Range.parse(sqlExpectation.rows()).max, sqlExpectation.threads(), sqlExpectation.query() for (SocketExpectation socketExpectation : socketExpectationList) { spy = spy.expect(new TcpConnections.TcpExpectation( Range.parse(socketExpectation.connections()).min, Range.parse(socketExpectation.connections()).max, socketExpectation.threads(), "".equals(socketExpectation.hostName()) ? null : socketExpectation.hostName()
@Test @SqlExpectation(count = @Count(max = 3)) public void testParseExpectation() throws NoSuchMethodException { Range range = Range.parse(RangeTest.class.getMethod("testParseExpectation").getAnnotation(SqlExpectation.class).count()); assertEquals(3, range.max); }