Source:
<code>public void extenderLifeCycleTest_noMoreInvokeBeforeAndAfterInitDeInit() { FakeLifecycleOwner lifecycle = new FakeLifecycleOwner(); PreviewExtenderImpl mockPreviewExtenderImpl = mock(PreviewExtenderImpl.class); PreviewExtender.PreviewExtenderAdapter previewExtenderAdapter = new PreviewExtender.PreviewExtenderAdapter(mockPreviewExtenderImpl); PreviewConfig.Builder configBuilder = new PreviewConfig.Builder().setUseCaseEventListener( previewExtenderAdapter); new Camera2Config.Extender(configBuilder).setCameraEventCallback( new CameraEventCallbacks(previewExtenderAdapter)); Preview useCase = new Preview(configBuilder.build()); CameraX.bindToLifecycle(lifecycle, useCase); lifecycle.startAndResume(); final SurfaceTextureCallable surfaceTextureCallable0 = new SurfaceTextureCallable(); final FutureTask<SurfaceTexture> future0 = new FutureTask<>(surfaceTextureCallable0); useCase.setOnPreviewOutputUpdateListener( new Preview.OnPreviewOutputUpdateListener() { @Override public void onUpdated(Preview.PreviewOutput previewOutput) { surfaceTextureCallable0.setSurfaceTexture( previewOutput.getSurfaceTexture()); future0.run(); } }); <START> InOrder inOrder = inOrder(mockPreviewExtenderImpl); <END> inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onInit(any(String.class), any( CameraCharacteristics.class), any(Context.class)); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onPresetSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onEnableSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).getCaptureStage(); CameraX.unbind(useCase); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onDisableSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onDeInit(); verifyNoMoreInteractions(mockPreviewExtenderImpl); }</code><technical_language>able move of verify calls unbind arrange-act-assert pattern</technical_language>

Target:
public void extenderLifeCycleTest_noMoreInvokeBeforeAndAfterInitDeInit() { FakeLifecycleOwner lifecycle = new FakeLifecycleOwner(); PreviewExtenderImpl mockPreviewExtenderImpl = mock(PreviewExtenderImpl.class); PreviewExtender.PreviewExtenderAdapter previewExtenderAdapter = new PreviewExtender.PreviewExtenderAdapter(mockPreviewExtenderImpl); PreviewConfig.Builder configBuilder = new PreviewConfig.Builder().setUseCaseEventListener( previewExtenderAdapter); new Camera2Config.Extender(configBuilder).setCameraEventCallback( new CameraEventCallbacks(previewExtenderAdapter)); Preview useCase = new Preview(configBuilder.build()); CameraX.bindToLifecycle(lifecycle, useCase); lifecycle.startAndResume(); useCase.setOnPreviewOutputUpdateListener(mock(Preview.OnPreviewOutputUpdateListener.class)); InOrder inOrder = inOrder(mockPreviewExtenderImpl); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onInit(any(String.class), any( CameraCharacteristics.class), any(Context.class)); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onPresetSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onEnableSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).getCaptureStage(); CameraX.unbind(useCase); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onDisableSession(); inOrder.verify(mockPreviewExtenderImpl, timeout(3000)).onDeInit(); verifyNoMoreInteractions(mockPreviewExtenderImpl); }