我正在尝试通过在本地集合中存储和提取传递的项目来模拟存储库对象。我声明了类范围参数:
data = data.loc[:, data.min().sort_values().index]
然后我尝试像这样模拟存储库:
import seaborn as sns
import pandas as pd
data = [[5,1,9],
[7,8,6],
[5,3,2]]
data = pd.DataFrame(data)
#sns.heatmap(data)
data = data.loc[:, data.min().sort_values().index]
#sns.heatmap(data) # Gives result in step 1
# Step1, Columsn sorted by min value, 1, 2, 5
data = [[1,9,5],
[8,6,7],
[3,2,5]]
data = pd.DataFrame(data)
#sns.heatmap(data)
# How do i perform step two, maintinaing column order.
# Step 2, Rows sorted by min value 1,2,7
data = [[1,9,5],
[3,2,5],
[8,6,7]]
data = pd.DataFrame(data)
sns.heatmap(data)
插入并获取所有项目的部件工作得很好,但是当我添加更新部件时,我开始出现如下错误:
@RunWith(MockitoJUnitRunner::class)
class ChangeItemCheckStateUseCaseTest : UseCaseTest<ChangeItemCheckStateUseCase>() {
@Mock
private lateinit var listItemsRepository: ListItemRepository
private lateinit var repositoryItems: MutableList<ListItem>
和
private fun mockItemsRepository() {
repositoryItems = mutableListOf()
`when`(listItemsRepository.insert(Mockito.anyList())).thenAnswer {
@Suppress("UNCHECKED_CAST")
repositoryItems.addAll(it.arguments[0] as? List<ListItem> ?: listOf())
}
`when`(listItemsRepository.getAllListItems()).thenReturn(
MutableLiveData<List<ListItem>>().also { it.value = repositoryItems }
)
`when`(listItemsRepository.updateItemCheckState(ArgumentMatchers.any(ListItem::class.java))).then {invocation ->
val argument = invocation.arguments[0] as ListItem
val index = repositoryItems.indexOf(repositoryItems.find { it.localId == argument.localId })
repositoryItems[index] = argument
Unit
}
}
和
java.lang.IllegalStateException: ArgumentMatchers.any(ListItem::class.java) must not be null