Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
dagger2
Search
funnelbit
April 20, 2015
560
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
dagger2
funnelbit
April 20, 2015
More Decks by funnelbit
See All by funnelbit
Hatena Engineer Seminar #9
funnelbit
5
7.5k
droidkaigi-2017-renovation
funnelbit
10
11k
Dart
funnelbit
0
300
BottomBarAndSnackBar
funnelbit
0
550
Dagger2 Optional bindings
funnelbit
0
620
WearableRecyclerView
funnelbit
1
840
QucikSettingsTileAPI
funnelbit
0
380
Mobile Vision
funnelbit
0
490
AwarenessAPI
funnelbit
0
170
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
410
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
Automating Front-end Workflow
addyosmani
1370
210k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
340
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
45k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
350
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
490
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
230
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
880
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Why Our Code Smells
bkeepers
PRO
340
58k
Transcript
%BHHFS JEGVOOFMCJU
ࣗݾհ w JEGVOOFMCJU ଜɹྋ w גࣜձࣾͯͳ w ΞϓϦέʔγϣϯΤϯδχΞ w
ڈ͔ΒΞϓϦ։ൃΛ࢝Ίͨ
%BHHFS
%BHHFS w IUUQTHJUIVCDPNHPPHMFEBHHFS w %*ίϯςφ w 4RVBSF͕։ൃͯͨ͠%BHHFSͷHPPHMFGPSL w ਖ਼ࣜ൛ ͍ͭઌϦϦʔε
w ։ൃ൛ͷ4/"14)05
%BHHFSͷϝϦοτ w ίϯύΠϧ࣌ʹίʔυੜ͠ґଘղܾ w KBWBYJOKFDU"OOPUBUJPOΛ༻ w ։ൃ͕׆ൃ
%BHHFS ༻ྫ
ߏΠϝʔδ .PEVMF &OUSZ.BOBHFS "DUJWJUZ &OUSZ.BOBHFS "QQMJDBUJPO $PNQPOFOU "1*$MJFOU
௨৴෦ public class BkumaFormalServiceProvider implements BkumaServiceProvider { … @Override public
BkumaService getService() { OkHttpClient client = new OkHttpClient(); RestAdapter restAdapter = new RestAdapter.Builder() .setClient(new OkClient(client)) .setEndpoint(BkumaService.END_POINT) .build(); return restAdapter.create(BkumaService.class); } …
.PEVMF͔Β*OKFDU @Module public class BkumaModule { private final BkumaService mBkumaService;
public BkumaModule(BkumaGirlsApplication application) { mBkumaService = new BkumaFormalServiceProvider(application .getApplicationContext()).getService(); @Provides @Singleton EntryManager provideEntryManager() { return new EntryManager(mBkumaService); } … public class MainActivity extends ActionBarActivity { @Inject EntryManager mEntryManager; @Override protected void onCreate(Bundle savedInstanceState) { … ((BkumaGirlsApplication)getApplication()).component() .inject(this); } … ௨৴෦
$PNQPOFOUΛ࡞Δ public class BKUMAGirlsApplication extends Application { @Singleton @Component(modules =
BkumaModule.class) public interface ApplicationComponent { void inject(MainActivity mainActivity); } private ApplicationComponent mComponent; @Override public void onCreate() { mComponent = DaggerBKUMAGirlsApplication_ApplicationComponent.builder() .bkumaModule(new BkumaModule(this)) .build(); } public ApplicationComponent component() { return mComponent; } }
%BHHFS ༻ྫ ςετ
.PEVMF ςετ @Module public class BkumaTestModule { private final BkumaService
mBkumaService; … public BkumaTestModule(InstrumentationTestCase instrumentationTestCase) { mBkumaService = new BkumaMockServiceProvider(mInstrumentationTestCase .getInstrumentation().getContext()).getService(); } @Provides EntryManager provideEntryManager() { return new EntryManager(mBkumaService); } … 5FTU༻ #LVNB4FSWJDF
௨৴෦ʢςετʣ @Override public BkumaService getService() { RestAdapter restAdapter = new
RestAdapter .Builder() .setEndpoint(BkumaService.END_POINT) .build(); MockRestAdapter mockRestAdapter = MockRestAdapter.from(restAdapter); mockRestAdapter.setDelay(0); …(ଓ͖·͢) 5FTU༻.PDL
௨৴෦ʢςετʣ … BkumaService bkumaService = new BkumaService() { @Override public
void getTopEntries(@Query("limit") int limit, Callback<List<EntryResponse>> callback) { callback.success( TestUtils.createDummyEntry(mContext, limit), createDummyJsonResponse() ); } }); return mockRestAdapter.create( BkumaService.class, bkumaService ); %VNNZ 3FTQPOTF
*OKFDU ςετ public class BkumaEntryManagerTest extends InstrumentationTestCase { … @Inject
EntryManager mEntryManager; … public testGetEntries() { assertEquals( "ΤϯτϦऔಘͰ͖͍ͯΔ", false, mEntryManager.getEntries().isEmpty()); } }
·ͱΊ w ςελϒϧͳίʔυ͕࡞Γ͍͢ w *OTUBODFཧ͕͘͢͠ͳΔ w "DUJWJUZͷ࠶ੜ࣌ͳͲʹޮ͍ͯ͘Δ
͋Γ͕ͱ͏͍͟͝·ͨ͠