Добрый день всем.
Я обновил библиотеку pushwoosh в build.gradle и после этого все тесты на robolectric стали падать с такой ошибкой:
java.lang.ExceptionInInitializerError
at com.pushwoosh.location.geofencer.GeofenceReceiver.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.robolectric.util.ReflectionHelpers.callConstructor(ReflectionHelpers.java:321)
at org.robolectric.internal.bytecode.ShadowImpl.newInstanceOf(ShadowImpl.java:20)
at org.robolectric.shadow.api.Shadow.newInstanceOf(Shadow.java:35)
at org.robolectric.shadows.ShadowApplication.registerBroadcastReceivers(ShadowApplication.java:138)
at org.robolectric.shadows.ShadowApplication.bind(ShadowApplication.java:127)
at org.robolectric.shadows.CoreShadowsAdapter.bind(CoreShadowsAdapter.java:71)
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:107)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:290)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:203)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:109)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:36)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:63)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Caused by: java.lang.NullPointerException
at com.pushwoosh.location.d.a.<init>(Unknown Source)
at com.pushwoosh.location.internal.a.<clinit>(Unknown Source)
... 33 more
Ниже мой тестовый файл:
@RunWith(CustomRobolectricRunner.class)
@Config(constants = BuildConfig.class)
@FragmentScope
public class LentaPresenterTest {
@Mock
private LentaItem lentaItemMock;
@Mock
private ChampionatRepository championatDataRepositoryMock;
@Mock
private CommentsRepository commentsRepositoryMock;
@Mock
private LocalRepository localRepositoryMock;
@Inject
BookmarkRepository bookmarkRepository;
@Mock
private LentaView lentaViewMock;
@Mock
private Exception exceptionMock;
@Inject
Context context;
@Inject
LocalRepository localRepository;
@Mock
private NetworkInfoManager networkInfoManager;
@Inject
protected LentaPresenter lentaPresenterTest;
private List<LentaItem> lentaItemListMock;
private Observable<GetLentaInteractor.LentaResponce> observable;
private Observable<Boolean> isShowFontObservable;
private TestScheduler testScheduler = Schedulers.test();
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
TestApp.getTestComponent().createTestActivityComponent(new TestActivityModule(mock(Activity.class))).
createTestFragmentComponent(new TestFragmentModule(mock(Fragment.class))).inject(this);
lentaPresenterTest = spy(lentaPresenterTest);
assert lentaPresenterTest.getLentaInteractor != null;
lentaItemListMock = new ArrayList<>();
lentaItemListMock.add(lentaItemMock);
observable = Observable.just(new GetLentaInteractor.LentaResponce(lentaItemListMock, 2));
lentaPresenterTest.setView(lentaViewMock);
lentaPresenterTest.getLentaInteractor = spy(new GetLentaInteractor(championatDataRepositoryMock, commentsRepositoryMock, localRepositoryMock, bookmarkRepository, networkInfoManager) {
@Override
public Subscription execute(LentaFilter lentaFilter, Subscriber<LentaResponce> subscriber) {
return observable.subscribe(subscriber);
}
});
lentaPresenterTest.isShowRatingViewInteractor = spy(new IsShowRatingViewInteractor(localRepository, context) {
@Override
protected Observable<Boolean> buildObservable() {
return isShowFontObservable;
}
});
lentaPresenterTest.isShowRatingViewInteractor.setJobScheduler(testScheduler);
lentaPresenterTest.isShowRatingViewInteractor.setIuScheduler(testScheduler);
}
@Test
public void interactorOnErrorTest() {
observable = Observable.error(exceptionMock);
lentaPresenterTest.initialize();
verify(lentaViewMock, times(1)).startProgress();
verify(lentaViewMock, times(1)).setSelectedSportsKinds(anyList());
verify(lentaViewMock, times(1)).showLayoutWithInformation();
verify(lentaViewMock, times(1)).stopProgress();
verifyNoMoreInteractions(lentaViewMock);
}
@Test
public void interactorOnErrorTest_showTop() {
observable = observable.concatWith(Observable.<GetLentaInteractor.LentaResponce>error(exceptionMock));
lentaPresenterTest.initialize();
verify(lentaViewMock, times(1)).startProgress();
verify(lentaViewMock, times(1)).setSelectedSportsKinds(anyList());
verify(lentaViewMock, times(1)).inflateData(anyList());
verify(lentaViewMock, times(1)).hideBottomErrorMessage();
verify(lentaViewMock, times(1)).showTopErrorMessage();
verify(lentaViewMock, times(1)).stopProgress();
verifyNoMoreInteractions(lentaViewMock);
}
@Test
public void interactorOnNextTest_first_request_true() {
isShowFontObservable = Observable.just(true);
lentaPresenterTest.lentaFilter = LentaFilter.EMPTY;
lentaPresenterTest.initialize();
testScheduler.triggerActions();
verify(lentaPresenterTest.getLentaInteractor, times(1)).execute(any(LentaFilter.class), any(Subscriber.class));
verify(lentaPresenterTest.isShowRatingViewInteractor, times(1)).execute(any(Subscriber.class));
verify(lentaViewMock, times(1)).inflateData(lentaItemListMock);
}
@Test
public void interactorOnNextTest_first_request_false() {
isShowFontObservable = Observable.just(true);
lentaPresenterTest.lentaFilter = LentaFilter.EMPTY.lentaBefore("before id");
lentaPresenterTest.initialize();
testScheduler.triggerActions();
verify(lentaPresenterTest.getLentaInteractor, times(1)).execute(any(LentaFilter.class), any(Subscriber.class));
verify(lentaPresenterTest.isShowRatingViewInteractor, times(1)).execute(any(Subscriber.class));
verify(lentaViewMock, times(1)).appendData(lentaItemListMock);
}
}
Мой build.gradle файл:
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile 'org.robolectric:shadows-multidex:3.3.2'
testCompile 'org.robolectric:shadows-play-services:3.1'
До обновления pushwoosh тесты отрабатывали все и корректно, сейчас же картина ровно до наоборот.
За помощь заранее спасибо!
Программа упрощенный калькуляторЕсть метод в котором сравниваются приоритеты математических операторов, но я не знаю как это сделать
Требуется чтобы массив содержал слова и знаки предложения на одном уровне, вроде:
Я написал программу при помощи Java, в которой есть главное окно для набора текста, окно для вывода сообщений и ошибок, а так же кнопка запуститьСвоеобразная...
Добрый день всемПытаюсь подключить библиотеку jquery-knob, устанавливал через npm install jquery-knob, в package-json она есть"jquery-knob": "^1