Forger


Source link: https://github.com/futuresimple/forger

Forger

Android library for populating the ContentProvider with test data.

Features

The library is tightly coupled with MicroOrm and Thneed projects. You need to annotate your data models fields with MicroOrm's @Column:

public class BaseModel {

@Column("id")
public long id; 
}
  public class Block extends BaseModel {

@Column(Blocks.BLOCK_TITLE)
public String title;
 @Column(Blocks.BLOCK_START)
public long blockStart;
 @Column(Blocks.BLOCK_END)
public long blockEnd; 
}
  public class Room extends BaseModel {

@Column(Rooms.ROOM_NAME)
public String name;
 @Column(Rooms.ROOM_FLOOR)
public String floor; 
}
  public class Session extends BaseModel {

@Column(Sessions.ROOM_ID)
public long roomId;
 @Column(Sessions.BLOCK_ID)
public long blockId;
 @Column(Sessions.SESSION_TITLE)
public String title; 
}
  // more models definitions...

Then you have to define the relationships between your data models using Thneed:

public interface DataModel extends ContentProviderModel, PojoModel {
 
}
  private DataModel ROOM = new DataModel {

// implementation 
}
  // ...  ModelGraph<DataModel> graph = ModelGraph.of(DataModel.class)
.where()
.the(SESSION).references(ROOM).by(Sessions.ROOM_ID)
.the(SESSION).references(BLOCK).by(Sessions.BLOCK_ID)
// more relationships definitions...
.build();

All this allows you to write code like this in your tests:

Forger<DataModel> forger = new Forger(graph, new MicroOrm());
  // create a simple object Room room = forger.iNeed(Room.class).in(myContentResolver);
 Block block = forger.iNeed(Block.class).in(myContentResolver);
  // create an object related to specific objects Session session = forger.iNeed(Session.class)
.relatedTo(room, block)
.in(myContentResolver);
  assertThat(session.room_id).isEqualTo(room.id);
 assertThat(session.block_id).isEqualTo(block.id);
  // create an object and automatically satisfy its dependencies Session session = forger.iNeed(Session.class).in(myContentResolver);
  assertThat(session.room_id).isNotEqualTo(0);
 assertThat(session.block_id).isNotEqualTo(0);

It might look like a lot of boilerplate code, but it still beats writing all helper methods for your tests by hand, especially when the number of data models and connections between them grows to several dozens.

Usage

Just add the dependency to your build.gradle:

dependencies {

  testCompile 'com.getbase.android.forger:forger:0.2' 
}

License

Copyright (C) 2013 Jerzy Chalupski  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.  

Resources

Drawable Badge is a android library for adding badges to drawables.

Reactive Auth APIs Wrapper Library for Google's Smart Lock for Passwords API.

ViewPrinter gives you live preview, edit and print functionality for View hierarchies, be it graphics, text, or whatever you draw in Android.

The ViewPrinter logo was created inside ViewPrinter itself! See the source code.

  • DocumentView, a live preview container for editable, zoomable, pannable views
  • Automatic splitting of text into pages and columns
  • Standardized or custom PrintSizes
  • Print to PDF, PNG or JPEG
  • System permissions handling

An android restful api/networking library using okhttp library as backbone.

Android 9.0+ support

A library for wrapping Firebase database with RxJava.

TypeYourPin is an android component made to provide a better experience when user types some PIN code.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes