Я написал тест метода, который имеет одно условие. Согласно условию он должен быть пустым и возвращать пустой ответ, но есть ошибка утверждения.
@Test
public void testExtractData_feedbackRecords_withBadWords() throws Exception {
//given
JSONArray tags = new JSONArray();
tags.put("ios_pre");
tags.put("andr_pre");
tags.put("web_pre");
JSONObject jsonObject = new JSONObject();
jsonObject.put("group_id", "28430278");
jsonObject.put("created_at", "2019-04-05T00:00:00Z");
jsonObject.put("updated_dt", "");
jsonObject.put("status", "status-test");
jsonObject.put("ticket_id", "1");
jsonObject.put("id", "1");
jsonObject.put("description", "----- Sender Info ----- Body:body1 adult platform=platform1");
JSONArray feedbackRecords = new JSONArray();
feedbackRecords.put(jsonObject);
JSONArray empty = new JSONArray();
JSONObject expected = new JSONObject();
expected.put("feedback", empty);
ZendeskExtractor mockZendeskExtractor = PowerMockito.mock(ZendeskExtractor.class);
PowerMockito.doReturn(feedbackRecords)
.when(mockZendeskExtractor, "extractFeedback", Mockito.any(String.class), Mockito.any(String.class));
when(mockZendeskExtractor.extractData("2019-04-05T00:00:00Z", DateTime.parse("2019-04-25T00:00:00Z")))
.thenCallRealMethod();
//when
JSONObject actualData =
mockZendeskExtractor.extractData("2019-04-05T00:00:00Z", DateTime.parse("2019-04-25T00:00:00Z"));
//then
assertEquals(expected, actualData);
}
Получение следующей ошибки:
java.lang.AssertionError: expected: org.json.JSONObject<{"feedback":[]}> but was: org.json.JSONObject<{"feedback":[]}>