Skip to content

Commit 2a60e05

Browse files
committed
Update unit test to make them more readable
1 parent d4dbebe commit 2a60e05

2 files changed

Lines changed: 21 additions & 16 deletions

File tree

‎AndroidAnnotations/functional-test-1-5-tests/src/test/java/org/androidannotations/test15/eintentservice/MyIntentServiceTest.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import static org.fest.assertions.Assertions.assertThat;
1919

2020
import org.androidannotations.test15.AndroidAnnotationsTestRunner;
21+
import org.androidannotations.test15.EmptyActivityWithoutLayout;
2122
import org.androidannotations.test15.EmptyActivityWithoutLayout_;
22-
import org.androidannotations.test15.eintentservice.IntentServiceHandledAction_.IntentBuilder_;
2323
import org.junit.Test;
2424
import org.junit.runner.RunWith;
2525

@@ -30,19 +30,19 @@ public class MyIntentServiceTest {
3030

3131
@Test
3232
public void testAction() {
33-
IntentServiceHandledAction_.actionForTestHandled = false;
33+
IntentServiceHandledAction.actionForTestHandled = null;
3434

3535
// Simulate call to intent builder and retrieve the configured Intent
36-
EmptyActivityWithoutLayout_ context = new EmptyActivityWithoutLayout_();
37-
IntentBuilder_ intentBuilder = IntentServiceHandledAction_.intent(
38-
context).myActionForTests();
39-
Intent intent = intentBuilder.get();
36+
EmptyActivityWithoutLayout context = new EmptyActivityWithoutLayout_();
37+
Intent intent = IntentServiceHandledAction_.intent(context) //
38+
.MyActionOneParam("test") //
39+
.get();
4040

4141
// Simulate the creation of IntentService by Android
42-
IntentServiceHandledAction_ intentServiceHandledAction = new IntentServiceHandledAction_();
42+
IntentServiceHandledAction intentServiceHandledAction = new IntentServiceHandledAction_();
4343
intentServiceHandledAction.onHandleIntent(intent);
4444

45-
assertThat(IntentServiceHandledAction_.actionForTestHandled).isTrue();
45+
assertThat(IntentServiceHandledAction_.actionForTestHandled).isEqualTo("test");
4646
}
4747

4848
}

‎AndroidAnnotations/functional-test-1-5/src/main/java/org/androidannotations/test15/eintentservice/IntentServiceHandledAction.java‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,39 @@
1515
*/
1616
package org.androidannotations.test15.eintentservice;
1717

18+
import org.androidannotations.annotations.Bean;
1819
import org.androidannotations.annotations.EIntentService;
1920
import org.androidannotations.annotations.ServiceAction;
21+
import org.androidannotations.test15.ebean.EnhancedClass;
2022

2123
import android.app.IntentService;
2224
import android.content.Intent;
2325

2426
@EIntentService
2527
public class IntentServiceHandledAction extends IntentService {
2628

27-
public static boolean actionForTestHandled = false;
29+
public static Object actionForTestHandled = null;
30+
31+
@Bean
32+
EnhancedClass dependency;
2833

2934
public IntentServiceHandledAction() {
3035
super(IntentServiceHandledAction.class.getSimpleName());
3136
}
3237

3338
@ServiceAction
34-
void myActionForTests() {
35-
actionForTestHandled = true;
39+
void myAction() {
40+
actionForTestHandled = new Object();
3641
}
3742

3843
@ServiceAction
39-
void actionOne() {
40-
actionForTestHandled = false;
44+
void MyActionOneParam(String valueString) {
45+
actionForTestHandled = valueString;
4146
}
4247

43-
@ServiceAction
44-
void myActionTwo() {
45-
actionForTestHandled = false;
48+
@ServiceAction("myAction")
49+
void myActionTwoParams(String valueString, long valueLong) {
50+
actionForTestHandled = valueString;
4651
}
4752

4853
@Override

0 commit comments

Comments
 (0)