com.google.appengine.tools.development.testing
Class LocalBasementServiceTestConfig
- java.lang.Object
-
- com.google.appengine.tools.development.testing.LocalBasementServiceTestConfig
-
- All Implemented Interfaces:
- LocalServiceTestConfig
public class LocalBasementServiceTestConfig extends java.lang.Object implements LocalServiceTestConfig
Config for accessing the LocalBasementService in tests. In order to verify that the expected data is being written, you will first need to provide anOutputStream
for the data to be written to:{@code private ByteArrayOutputStream protoStream = new ByteArrayOutputStream(); LocalServiceTestHelper helper;
-
-
Constructor Summary
Constructors Constructor and Description LocalBasementServiceTestConfig()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description LocalBasementServiceTestConfig
addGaiaMintAllowedScope(GaiaMintScopeCode.ScopeCode allowedScope)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that the specificGaiaMintScopeCode.ScopeCode
is allowed.static LocalBasementService
getLocalBasementService()
LocalBasementServiceTestConfig
setClock(Clock clock)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the specified (@link com.google.common.time.Clock) when determing the current time.LocalBasementServiceTestConfig
setGaiaMintAuthDomain(java.lang.String authDomain)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified auth domain from calls toGaiaMintService#getUserinfoFromGaiaMint
.LocalBasementServiceTestConfig
setGaiaMintEmail(java.lang.String email)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified email address from calls toGaiaMintService#getUserinfoFromGaiaMint
.LocalBasementServiceTestConfig
setGaiaMintGaiaId(long gaiaId)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified gaid ID from calls toGaiaMintService#getUserinfoFromGaiaMint
.LocalBasementServiceTestConfig
setGaiaMintIsAdmin(boolean isAdmin)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return whether the user is an admin from calls toGaiaMintService#getUserinfoFromGaiaMint
.LocalBasementServiceTestConfig
setGaiaMintUserId(java.lang.String userId)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified user id from calls toGaiaMintService#getUserinfoFromGaiaMint
.LocalBasementServiceTestConfig
setLogToSawmillEnable(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
with the specified enable state.LocalBasementServiceTestConfig
setLogToSawmillIgnore(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
with the specified ignore state.LocalBasementServiceTestConfig
setLogToSawmillLogEveryCall(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will log every call toLogToSawmillService#log(byte[])
withLogger
.LocalBasementServiceTestConfig
setLogToSawmillProtoStream(java.io.OutputStream out)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will write a request's final merged proto to the specifiedOutputStream
.LocalBasementServiceTestConfig
setOneGoogleServerSpec(java.lang.String serverSpec)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the specified server spec for the OneGoogle backend instead of the default (seeLocalBasementService.ONE_GOOGLE_SERVER_SPEC_DEFAULT
).LocalBasementServiceTestConfig
setOneGoogleStub(OneGoogleServerProto.OneGoogleService.Stub stub)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the the specifiedOneGoogleServerProto.OneGoogleService.Stub
to send RPCs to the OneGoogleService server.void
setUp()
Set up the local service.void
tearDown()
Tear down the local service.
-
-
-
Method Detail
-
setUp
public void setUp()
Description copied from interface:LocalServiceTestConfig
Set up the local service.- Specified by:
setUp
in interfaceLocalServiceTestConfig
-
tearDown
public void tearDown()
Description copied from interface:LocalServiceTestConfig
Tear down the local service.- Specified by:
tearDown
in interfaceLocalServiceTestConfig
-
getLocalBasementService
public static LocalBasementService getLocalBasementService()
-
setLogToSawmillProtoStream
public LocalBasementServiceTestConfig setLogToSawmillProtoStream(java.io.OutputStream out)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will write a request's final merged proto to the specifiedOutputStream
. If this method is not called or is called withnull
, the final merged proto will not be written. Defaults tonull
and must be called (note: only applies to unit tests, in the Dev App Server defaults to writing to the filesystem). The final merged proto is only written once the request is over. You can indicate this to the unit test by either callingLocalServiceTestHelper#endRequest()
orLocalServiceTestHelper#tearDown()
. This method must be called prior to callingLocalServiceTestHelper#setUp()
.- Parameters:
out
- A non-closed OutputStream.- Returns:
- itself for call chaining
-
setLogToSawmillEnable
public LocalBasementServiceTestConfig setLogToSawmillEnable(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
with the specified enable state. When disabled, the entry points will throw just like the production environment when the app is missing the SAWMILL_APP_EXTENSIONS_ENABLE permission. Defaults totrue
. This method must be called prior to callingLocalServiceTestHelper#setUp()
.- Parameters:
b
- True to allow the service to log.- Returns:
- itself for call chaining
-
setLogToSawmillIgnore
public LocalBasementServiceTestConfig setLogToSawmillIgnore(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
with the specified ignore state. When ignored,LogToSawmillService#log(byte[])
will drop all date and the entry points will indicate this in their return value. Defaults tofalse
. This method must be called prior to callingLocalServiceTestHelper#setUp()
.- Parameters:
b
- False to allow the service to log.- Returns:
- itself for call chaining
-
setLogToSawmillLogEveryCall
public LocalBasementServiceTestConfig setLogToSawmillLogEveryCall(boolean b)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will log every call toLogToSawmillService#log(byte[])
withLogger
. Defaults tofalse
(note: only applies to unit tests; in the Dev App Server defaults totrue
). This method must be called prior to callingLocalServiceTestHelper#setUp()
.- Parameters:
b
- True to have the local service log each call.- Returns:
- itself for call chaining
-
setGaiaMintEmail
public LocalBasementServiceTestConfig setGaiaMintEmail(java.lang.String email)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified email address from calls toGaiaMintService#getUserinfoFromGaiaMint
. Defaults to "example@example.com". This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
email
- The email address to return fromGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
setGaiaMintUserId
public LocalBasementServiceTestConfig setGaiaMintUserId(java.lang.String userId)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified user id from calls toGaiaMintService#getUserinfoFromGaiaMint
. Defaults to "135705915318242114242". This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
userId
- The user id to return fromGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
setGaiaMintAuthDomain
public LocalBasementServiceTestConfig setGaiaMintAuthDomain(java.lang.String authDomain)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified auth domain from calls toGaiaMintService#getUserinfoFromGaiaMint
. Defaults to "gmail.com". This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
authDomain
- The auth domain to return fromGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
setGaiaMintIsAdmin
public LocalBasementServiceTestConfig setGaiaMintIsAdmin(boolean isAdmin)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return whether the user is an admin from calls toGaiaMintService#getUserinfoFromGaiaMint
. Defaults to false. This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
isAdmin
- Whether to make the user an admin in calls toGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
setGaiaMintGaiaId
public LocalBasementServiceTestConfig setGaiaMintGaiaId(long gaiaId)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that it will return the specified gaid ID from calls toGaiaMintService#getUserinfoFromGaiaMint
. Defaults to 8242114242L. This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
authDomain
- The gaia ID to return fromGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
addGaiaMintAllowedScope
public LocalBasementServiceTestConfig addGaiaMintAllowedScope(GaiaMintScopeCode.ScopeCode allowedScope)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
so that the specificGaiaMintScopeCode.ScopeCode
is allowed. Calls toGaiaMintService#getUserinfoFromGaiaMint
with non allowed scopes will fail. If the allowed list of scopes code is empty or it includesGaiaMintScopeCode.ScopeCode#API_ALL_SCOPES
all scopes will be allowed. This method must be called prior to callingLocalServiceTestHelper.setUp()
.- Parameters:
allowedScope
- AGaiaMintScopeCode.ScopeCode
to allow for calls toGaiaMintService#getUserinfoFromGaiaMint
.- Returns:
- itself for call chaining
-
setOneGoogleServerSpec
public LocalBasementServiceTestConfig setOneGoogleServerSpec(java.lang.String serverSpec)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the specified server spec for the OneGoogle backend instead of the default (seeLocalBasementService.ONE_GOOGLE_SERVER_SPEC_DEFAULT
). NOTE: most unit tests should not bother with this method and should usesetOneGoogleStub( OneGoogleServerProto.OneGoogleService.Stub)
to install a mock stub.- Parameters:
serverSpec
- the OneGoogle backend server spec to connect to- Returns:
- itself for call chaining
-
setOneGoogleStub
public LocalBasementServiceTestConfig setOneGoogleStub(OneGoogleServerProto.OneGoogleService.Stub stub)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the the specifiedOneGoogleServerProto.OneGoogleService.Stub
to send RPCs to the OneGoogleService server.- Parameters:
stub
- aOneGoogleServerProto.OneGoogleService.Stub
- Returns:
- itself for call chaining
-
setClock
public LocalBasementServiceTestConfig setClock(Clock clock)
Configure theLocalBasementServiceTestConfig
to create theLocalBasementService
to use the specified (@link com.google.common.time.Clock) when determing the current time.- Parameters:
clock
- acom.google.common.time.Clock
- Returns:
- itself for call chaining
-
-