### Question:
MongoDbOAuthTokenInfoRepository implements OAuthTokenInfoRepository { @Override public OAuthTokenInfo save(OAuthTokenInfo item) { template.save(item, OAUTH_TOKEN_COLLECTION); return item; }  @Override OAuthTokenInfo findOAuthTokenInfo(String userId, String appUrl, String moduleId, String tokenName, String serviceName); @Override Class<? extends OAuthTokenInfo> getType(); @Override OAuthTokenInfo get(String id); @Override OAuthTokenInfo save(OAuthTokenInfo item); @Override void delete(OAuthTokenInfo item); @Override List<OAuthTokenInfo> getAll(); @Override List<OAuthTokenInfo> getLimitedList(int offset, int limit); @Override int getCountAll(); void setTemplate(MongoOperations template); static final Class<OAuthTokenInfoImpl> CLASS; }### Answer:
@Test public void save_null(){ OAuthTokenInfo info = new OAuthTokenInfoImpl(); OAuthTokenInfo result; template.save(isA(OAuthTokenInfo.class), eq(OAUTH_TOKEN_COLLECTION)); expectLastCall(); replay(template); result = repo.save(info); verify(template); }
@Test public void save(){ OAuthTokenInfo item = new OAuthTokenInfoImpl("appUrl", "serviceName", "tokenName", "accessToken", "sessionHandle", "tokenSecret", "userId", 1111L); OAuthTokenInfo result; item.setId("1234L"); template.save(isA(OAuthTokenInfo.class), eq(OAUTH_TOKEN_COLLECTION)); expectLastCall(); result = repo.save(item); assertNotNull(result.getId()); assertThat(result.getId(), is(equalTo("1234L"))); }