Java Code Examples for com.googlecode.objectify.ObjectifyService#register()

The following examples show how to use com.googlecode.objectify.ObjectifyService#register() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportUtilsTest.java    From tech-gallery with Apache License 2.0 6 votes vote down vote up
/**
 * Setup method for the test.
 */
@Before
public void setUp() {

  helper.setUp();
  ObjectifyService.register(TechGalleryUser.class);
  ObjectifyService.register(UserProfile.class);
  ObjectifyService.register(Technology.class);
  ObjectifyService.begin();

  createProfiles();

  ObjectifyService.ofy().save().entity(techGalleryUser).now();
  ObjectifyService.ofy().save().entity(techGalleryUser2).now();
  ObjectifyService.ofy().save().entity(userProfile).now();
  ObjectifyService.ofy().save().entity(userProfile2).now();
}
 
Example 2
Source File: SignGuestbookServletTest.java    From java-docs-samples with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

  MockitoAnnotations.initMocks(this);
  helper.setUp();
  ds = DatastoreServiceFactory.getDatastoreService();

  //  Set up some fake HTTP requests
  when(mockRequest.getRequestURI()).thenReturn(FAKE_URL);
  when(mockRequest.getParameter("guestbookName")).thenReturn("default2");
  when(mockRequest.getParameter("content")).thenReturn(testPhrase);

  stringWriter = new StringWriter();
  when(mockResponse.getWriter()).thenReturn(new PrintWriter(stringWriter));

  servletUnderTest = new SignGuestbookServlet();

  ObjectifyService.init();
  ObjectifyService.register(Guestbook.class);
  ObjectifyService.register(Greeting.class);

  closeable = ObjectifyService.begin();

  cleanDatastore(ds, "default");
}
 
Example 3
Source File: OpenedServletTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 4
Source File: ObjectifyJacksonModuleTest.java    From gwt-jackson with Apache License 2.0 5 votes vote down vote up
@Override
public void setUp() {
    super.setUp();
    helper.setUp();
    closeable = ObjectifyService.begin();
    ObjectifyService.register( Bean.class );
    objectMapper.registerModule( new ObjectifyJacksonModule() );
    ObjectifyService.ofy().save().entity( ObjectifyAbstractTester.BEAN ).now();
}
 
Example 5
Source File: ContextListener.java    From appstart with Apache License 2.0 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent event) {
	super.contextInitialized(event);
	// Register you objectify entities here
	ObjectifyService.register(Todo.class);
	log.info("Context created");

}
 
Example 6
Source File: ContextListener.java    From appstart with Apache License 2.0 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent event) {
	super.contextInitialized(event);
	// Register you objectify entities here
	ObjectifyService.register(Todo.class);
	log.info("Context created");

}
 
Example 7
Source File: OfyHelper.java    From teammates with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Register entity classes in Objectify service.
 */
public static void registerEntityClasses() {
    ObjectifyService.register(Account.class);
    ObjectifyService.register(Course.class);
    ObjectifyService.register(CourseStudent.class);
    ObjectifyService.register(FeedbackQuestion.class);
    ObjectifyService.register(FeedbackResponse.class);
    ObjectifyService.register(FeedbackResponseComment.class);
    ObjectifyService.register(FeedbackSession.class);
    ObjectifyService.register(Instructor.class);
    ObjectifyService.register(StudentProfile.class);
    // enable the ability to use java.time.Instant to issue query
    ObjectifyService.factory().getTranslators().add(new BaseEntity.InstantTranslatorFactory());
}
 
Example 8
Source File: MoveServletTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 9
Source File: DeleteServletTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 10
Source File: ContextInitialiser.java    From raspberrypi-appengine-portal with Apache License 2.0 5 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent sce) {
	
	ObjectifyService.register(SensorData.class);
	ObjectifyService.register(Client.class);
	log.info("Context created");
}
 
Example 11
Source File: TicTacToeServletTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUpBeforeClass() {
  // Reset the Factory so that all translators work properly.
  ObjectifyService.setFactory(new ObjectifyFactory());
  ObjectifyService.register(Game.class);
  // Mock out the firebase config
  FirebaseChannel.firebaseConfigStream =
      new ByteArrayInputStream(String.format("databaseURL: \"%s\"", FIREBASE_DB_URL).getBytes());
}
 
Example 12
Source File: GreetingTest.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

  helper.setUp();
  ds = DatastoreServiceFactory.getDatastoreService();

  ObjectifyService.init();
  ObjectifyService.register(Guestbook.class);
  ObjectifyService.register(Greeting.class);

  closeable = ObjectifyService.begin();

  cleanDatastore(ds, "default");
}
 
Example 13
Source File: OfyHelper.java    From java-docs-samples with Apache License 2.0 5 votes vote down vote up
/**
 * A ServletContextListener initializer.
 * @param event .
 */
public void contextInitialized(ServletContextEvent event) {
  // This will be invoked as part of a warmup request, or the first user request if no warmup
  // request.
  ObjectifyService.init();
  ObjectifyService.register(Guestbook.class);
  ObjectifyService.register(Greeting.class);
}
 
Example 14
Source File: EndorsementServiceTest.java    From tech-gallery with Apache License 2.0 5 votes vote down vote up
/**
 * Setup method for the test.
 */
@Before
public void setUp() {
  helper.setUp();
  ObjectifyService.register(TechGalleryUser.class);
  ObjectifyService.register(Endorsement.class);
  ObjectifyService.begin();
}
 
Example 15
Source File: OfyHelper.java    From appengine-java-guestbook-multiphase with Apache License 2.0 4 votes vote down vote up
public void contextInitialized(ServletContextEvent event) {
  // This will be invoked as part of a warmup request, or the first user request if no warmup
  // request.
  ObjectifyService.register(Guestbook.class);
  ObjectifyService.register(Greeting.class);
}
 
Example 16
Source File: ObjectifyDAOTest.java    From divide with Apache License 2.0 4 votes vote down vote up
public ObjectifyDAOTest(){
    super(new ObjectifyDAO());
    ObjectifyService.register(OfyObject.class);
}
 
Example 17
Source File: ObjectifyBenchmarkTest.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    ObjectifyService.register(Root.class);
    ObjectifyService.register(Data.class);
}
 
Example 18
Source File: ObjectifyInitializer.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent sce) {
  ObjectifyService.register(WaxSession.class);
}
 
Example 19
Source File: ObjectifyHelper.java    From java-docs-samples with Apache License 2.0 2 votes vote down vote up
/**
 * This will be invoked as part of a warmup request, or the first user request if no warmup
 * request.
 * @param event ServletContextEvent.
 */
public void contextInitialized(ServletContextEvent event) {
  //
  ObjectifyService.register(Game.class);
}