@Test public void givenAlreadyAddedAspectWhenWithOtherAspectThenShouldRegister() { context.withAspect(AnAspect.class); context.withAspect(OtherAspect.class); verify(weaverMock).registerAspect(OtherAspect.class); }
@Test public void whenFromClassThenTheSourceIsSetToTheSameTypeAndName() { context.from(Date.class); CallSource source = context.getConfiguredCallSource(); assertSame(Date.class, source.getType()); assertEquals(Date.class.getName(), source.getName()); }
@Test public void whenWithAspectMultipleTimesThenShouldNotResetAndShouldRegisterEveryAspect() { context.withAspect(AnAspect.class); context.withAspect(OtherAspect.class); verify(weaverMock, times(2)).registerAspect((Class<?>) anyObject()); verifyNoMoreInteractions(weaverMock); }
public MigrationCallContext( final CallContext context, final DateTime createdDate, final DateTime updatedDate) { super( context.getTenantId(), context.getUserName(), context.getCallOrigin(), context.getUserType()); this.createdDate = createdDate; this.updatedDate = updatedDate; }
@Test public void whenWithAspectShouldRegisterTheAspectOnTheWeaver() { Class<?> theAspect = AnAspect.class; context.withAspect(theAspect); verify(weaverMock).registerAspect(theAspect); }
/** * Foreign function. Dynamically executes an AMOSQL statement. Declare as create function * jeval(charstring)->object as foreign "JAVA:EvalTest/javaEval"; */ public void javaEval(CallContext cxt, Tuple tpl) throws AmosException { Scan tmpScan; Tuple t; // Pick up the argument String query = tpl.getStringElem(0); try { System.out.println("Executing " + query); tmpScan = cxt.connection().execute(query); while (!tmpScan.eos()) { t = tmpScan.getRow(); tpl.setElem(1, t.getOidElem(0)); cxt.emit(tpl); tmpScan.nextRow(); } } catch (AmosException e) { throw (e); } }
@Test public void whenFromSourceThenTheSameSourceIsReturned() { CallSource specifiedSource = mock(CallSource.class); context.from(specifiedSource); assertSame(specifiedSource, context.getConfiguredCallSource()); }
/** * Get and load a properties file from the writable area or if that fails from the classpath * (where a default ought to be stored) * * @param subject The name of the desired resource (without any extension) * @return The found and loaded properties file * @throws IOException if the resource can not be loaded * @throws MissingResourceException if the resource can not be found */ public static Properties getProperties(String subject) throws IOException { return getProperties(CallContext.getCallingClass(), subject); }
/** * Generic resource URL fetcher * * @return The requested resource * @throws IOException if there is a problem reading the file * @throws MissingResourceException if the resource can not be found */ public static InputStream getResourceAsStream(String search) throws IOException, MissingResourceException { return getResourceAsStream(CallContext.getCallingClass(), search); }
/** * Generic resource URL fetcher. One way or the other we'll find it! Either as a relative or an * absolute reference. * * @param search The name of the resource (without a leading /) to find * @return The requested resource * @throws MissingResourceException if the resource can not be found */ public static URL getResource(String search) throws MissingResourceException { return getResource(CallContext.getCallingClass(), search); }
@Override public ListenableFuture<ResponseT> futureCall(RequestT request, CallContext context) { Preconditions.checkNotNull(request); return ClientCalls.futureUnaryCall( factory.newCall(context.getChannel(), context.getCallOptions()), request); }