有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

javacom。亚马逊。AmazonServiceException:只能使用“筛选器表达式”、“查询筛选器”或“关键条件”中的一种

我正试图为这段代码编写junit,它给出了错误“'Can only use one of 'filter expression', 'query filter' or 'key condition'” 我使用@Mock注释模拟了对象。我在写junit的时候遗漏了什么吗

//TestRepositoryImpl
            QuerySpec querySpec = new QuerySpec();

        ItemCollection<QueryOutcome> items = null;
        
        querySpec.withHashKey(id, dealerId).withFilterExpression("date >= :d")
                .withValueMap(new ValueMap().withLong(":d", date)).withConsistentRead(true);
        items = table.query(querySpec);
        
        List<Test> testlist = new ArrayList<>();
        for (Item item : items) {
            Test test = objectMapper.readValue(item.toJSONPretty(), Test.class);
            testlist.add(eventslog);
        }

下面是测试代码

@Mock

Table table;

@Mock
ItemCollection<QueryOutcome> items;

@Mock
ObjectMapper objectMapper;
private TestRepositoryImpl sut;


@Test
void getEventLogList() throws JsonMappingException, JsonProcessingException {
    
    when(table.query(any(QuerySpec.class))).thenReturn(items);
    List<EventLog> list = sut.getEventlog("1613043840", "id456");
    //assertNotNull(eventlogList);
    assertNotNull(list);
}

共 (0) 个答案