Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewModelにcontext渡さない #112

Merged
merged 5 commits into from
Jul 22, 2023

Conversation

kosenda
Copy link
Owner

@kosenda kosenda commented Jul 20, 2023

Issue

#97

Overview

  • ErrorInterceptorにもApplicationContextを渡してしまっていたのでConvertViewModelのメソッドconvertと併せてcontextを渡さないようにした
  • エラーの文言はScreenで日本語または英語に変換するようにし、今回作成した2つ(enumのConvertErrorType、カスタムException3種類(ConvertTextUseCaseError.kt))を経由するようにした
  • テストは今回すべてコメントにして全体的に修正する

@kosenda kosenda marked this pull request as draft July 20, 2023 16:19
@kosenda kosenda changed the title [WIP]ViewModelにcontext渡さない ViewModelにcontext渡さない Jul 22, 2023
@KSNDBOT
Copy link
Collaborator

KSNDBOT commented Jul 22, 2023

2 Warnings
⚠️ Big PR
⚠️ No coverage data found for ksnd/hiraganaconverter/model/usecase/ConvertTextUseCaseError

JaCoCo Code Coverage 0.58% ✅

Class Covered Meta Status
ksnd/hiraganaconverter/model/usecase/ConvertTextUseCase 0% 0%
ksnd/hiraganaconverter/model/usecase/ConvertTextUseCaseError No coverage data found : -% No coverage data found : -% 🃏
ksnd/hiraganaconverter/viewmodel/ConvertViewModel 0% 0%
ksnd/hiraganaconverter/viewmodel/ConvertViewModelImpl 0% 0%
ksnd/hiraganaconverter/model/repository/ConvertRepositoryImpl 0% 0%
ksnd/hiraganaconverter/model/ErrorInterceptor 0% 0%
ksnd/hiraganaconverter/model/ConvertErrorType 0% 0%

Generated by 🚫 Danger

convertHistoryDataList.value.removeIf { it.id == id }
}
}
//class ConvertHistoryRepositoryImplTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// convertHistoryRepositoryImpl.deleteConvertHistory(id = histories[1].id)
// assertThat(convertHistoryRepositoryImpl.getAllConvertHistory().size).isEqualTo(2)
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
//}
//
//private class FakeConvertHistoryDao : ConvertHistoryDao {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// override fun deleteConvertHistory(id: Long) {
// convertHistoryDataList.value.removeIf { it.id == id }
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
}
}
//@OptIn(ExperimentalCoroutinesApi::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
//class DataStoreRepositoryImplTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
// }
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

testData.removeIf { deleteTarget -> deleteTarget.id == id }
}
}
//@OptIn(ExperimentalCoroutinesApi::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
}
//@OptIn(ExperimentalCoroutinesApi::class)
//class ConvertHistoryViewModelImplTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
//
// // ■ 変換履歴の詳細ダイアログに関するテスト ------------------------------------------------- End
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// // ■ 変換履歴の詳細ダイアログに関するテスト ------------------------------------------------- End
//}
//
//private class FakeConvertHistoryRepository(exitsInitData: Boolean) : ConvertHistoryRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// override fun deleteConvertHistory(id: Long) {
// testData.removeIf { deleteTarget -> deleteTarget.id == id }
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

override suspend fun updateCustomFont(newCustomFont: CustomFont) {}
override suspend fun checkReachedConvertMaxLimit(today: String) = isReachedConvertMaxLimit
}
//@OptIn(ExperimentalCoroutinesApi::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

override suspend fun checkReachedConvertMaxLimit(today: String) = isReachedConvertMaxLimit
}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
//class ConvertViewModelImplTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// assertThat(viewModel.uiState.value.outputText).isNotEqualTo("")
// }
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
//}
//
//private fun createTestingConvertViewModel(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// testDispatcher: CoroutineDispatcher,
// isErrorResponse: Boolean,
// isReachedConvertMaxLimit: Boolean,
//): ConvertViewModelImpl {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// ioDispatcher = testDispatcher,
// defaultDispatcher = testDispatcher,
// )
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// )
//}
//
//@OptIn(ExperimentalSerializationApi::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

//}
//
//@OptIn(ExperimentalSerializationApi::class)
//private class FakeConverterRepository(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

//private class FakeConverterRepository(
// context: Context,
// isErrorResponse: Boolean,
//) : ConvertRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// val body = json.toRequestBody(contentType)
// return runBlocking { convertService.requestConvert(body) }
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
//}
//
//private class FakeInterceptor(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

//private class FakeInterceptor(
// private val isErrorResponse: Boolean,
// private val context: Context,
//) : Interceptor {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// .request(request)
// .build()
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// }
//}
//
//private class FakeConvertHistoryRepositoryImpl : ConvertHistoryRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// override fun getAllConvertHistory(): List<ConvertHistoryData> = emptyList()
// override fun deleteAllConvertHistory() {}
// override fun deleteConvertHistory(id: Long) {}
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// override fun deleteConvertHistory(id: Long) {}
//}
//
//private class FakeDataStoreRepositoryImpl(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

//
//private class FakeDataStoreRepositoryImpl(
// private val isReachedConvertMaxLimit: Boolean,
//) : DataStoreRepository {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// override suspend fun updateThemeNum(newThemeNum: Int) {}
// override suspend fun updateCustomFont(newCustomFont: CustomFont) {}
// override suspend fun checkReachedConvertMaxLimit(today: String) = isReachedConvertMaxLimit
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

assertThat(viewModel.isSelectedFont(CustomFont.DEFAULT)).isFalse()
}
}
//@OptIn(ExperimentalCoroutinesApi::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

}
//@OptIn(ExperimentalCoroutinesApi::class)
//@RunWith(RobolectricTestRunner::class)
//class SettingsViewModelImplTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

// assertThat(viewModel.isSelectedFont(CustomFont.BIZ_UDGOTHIC)).isTrue()
// assertThat(viewModel.isSelectedFont(CustomFont.DEFAULT)).isFalse()
// }
//}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing space after //

@kosenda kosenda marked this pull request as ready for review July 22, 2023 05:48
@kosenda kosenda merged commit bc8c561 into main Jul 22, 2023
@kosenda kosenda deleted the refactor/remove-context-from-viewmodel-method-param branch July 22, 2023 05:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants