This commit is contained in:
Igor Popov 2017-09-20 20:27:00 +03:00
Родитель 80ca85859b
Коммит cd4b4ff451
3 изменённых файлов: 244 добавлений и 798 удалений

Просмотреть файл

@ -10,20 +10,28 @@ protocol ActivityInteractorOutput: class {
}
protocol ActivityInteractorInput {
}
class Service {
protocol ActivityService: class {
func loadFollowingActivities(cursor: String?, limit: Int, completion: (Result<FeedResponseActivityView>) -> Void)
func loadPendingsRequests(cursor: String?, limit: Int, completion: (Result<FeedResponseUserCompactView>) -> Void)
}
class ActivityServiceMock: ActivityService {
let authorization = "String"
var followingActivitiesResponse: Result<FeedResponseActivityView>!
var pendingRequestsResponse: Result<FeedResponseUserCompactView>!
func builder<T>(cursor: String?, limit: Int) -> RequestBuilder<T>? {
switch T.self {
case is FeedResponseUserCompactView.Type:
let result = SocialAPI.myPendingUsersGetPendingUsersWithRequestBuilder(authorization: authorization,
cursor: cursor,
limit: Int32(limit))
cursor: cursor,
limit: Int32(limit))
return result as? RequestBuilder<T>
default:
@ -31,16 +39,16 @@ class Service {
}
}
func load(cursor: String?, limit: Int, completion: (Result<FeedResponseActivityView>) -> Void) {
completion(.success(FeedResponseActivityView().mockResponse()))
func loadFollowingActivities(cursor: String?, limit: Int, completion: (Result<FeedResponseActivityView>) -> Void) {
completion(followingActivitiesResponse)
}
func load(cursor: String?, limit: Int, completion: (Result<FeedResponseUserCompactView>) -> Void) {
completion(.success(FeedResponseUserCompactView().mockResponse()))
func loadPendingsRequests(cursor: String?, limit: Int, completion: (Result<FeedResponseUserCompactView>) -> Void) {
completion(pendingRequestsResponse)
}
func test<T: Any>(cursor: String?, limit: Int, completion: (Result<T>) -> Void) {
guard let builder: RequestBuilder<T> = self.builder(cursor: cursor, limit: limit) else {
fatalError("Builder not found")
}
@ -95,7 +103,7 @@ class ActivityInteractor {
weak var output: ActivityInteractorOutput!
fileprivate var service: Service = Service()
var service: ActivityServiceMock = ActivityServiceMock()
fileprivate var followersList: FollowersActivitiesList = FollowersActivitiesList()
fileprivate var pendingRequestsList: PendingRequestsList = PendingRequestsList()
fileprivate var loadingPages: Set<PageID> = Set()
@ -104,9 +112,9 @@ class ActivityInteractor {
fileprivate var isLoading: Bool = false
// fileprivate var followingPages: [FollowingPage] = []
// fileprivate var pendingRequestsPages: [PendingRequestPage] = []
// fileprivate var followingPages: [FollowingPage] = []
// fileprivate var pendingRequestsPages: [PendingRequestPage] = []
}
protocol ResponseProcessor {
@ -119,7 +127,7 @@ protocol ResponseProcessor {
class ActionItemResponseProcessor: ResponseProcessor {
typealias ResponseType = FeedResponseActivityView
typealias ResultType = ActionItem
func process(response: ResponseType, pageID: String) -> PageModel<ResultType>? {
var items = [ActionItem]()
@ -133,7 +141,7 @@ class ActionItemResponseProcessor: ResponseProcessor {
return PageModel<ActionItem>(uid: pageID, cursor: response.cursor, items: items)
}
}
extension ActivityInteractor: ActivityInteractorInput {
@ -173,78 +181,79 @@ extension ActivityInteractor: ActivityInteractorInput {
pendingRequestsList = PendingRequestsList()
loadingPages = Set()
// loadNextPage()
// loadNextPage()
}
// TODO: remake using generics
func loadNextPage(completion: ((Result<[ActionItem]>) -> Void)? = nil) {
func loadNextPageFollowingActivities(completion: ((Result<[ActionItem]>) -> Void)? = nil) {
let pageID = UUID().uuidString
loadingPages.insert(pageID)
service.load(cursor: followersList.cursor,
limit: followersList.limit) { [weak self] (result: Result<FeedResponseActivityView>) in
defer {
loadingPages.remove(pageID)
}
// exit on released or canceled
guard let strongSelf = self, strongSelf.loadingPages.contains(pageID) else {
return
}
// must have data
guard let response = result.value else {
completion?(.failure(ActivityError.noData))
return
}
// map data into page
guard let page = strongSelf.process(response: response, pageID: pageID) else {
completion?(.failure(ActivityError.notParsable))
return
}
strongSelf.followersList.add(page: page)
completion?(.success(page.items))
service.loadFollowingActivities(cursor: followersList.cursor,
limit: followersList.limit) { [weak self] (result: Result<FeedResponseActivityView>) in
defer {
loadingPages.remove(pageID)
}
// exit on released or canceled
guard let strongSelf = self, strongSelf.loadingPages.contains(pageID) else {
return
}
// must have data
guard let response = result.value else {
completion?(.failure(ActivityError.noData))
return
}
// map data into page
guard let page = strongSelf.process(response: response, pageID: pageID) else {
completion?(.failure(ActivityError.notParsable))
return
}
strongSelf.followersList.add(page: page)
completion?(.success(page.items))
}
}
func loadNextPage(completion: ((Result<[PendingRequestItem]>) -> Void)? = nil) {
func loadNextPagePendigRequestItems(completion: ((Result<[PendingRequestItem]>) -> Void)? = nil) {
let pageID = UUID().uuidString
loadingPages.insert(pageID)
service.load(cursor: followersList.cursor,
limit: followersList.limit) { [weak self] (result: Result<FeedResponseUserCompactView>) in
defer {
loadingPages.remove(pageID)
}
// exit on released or canceled
guard let strongSelf = self, strongSelf.loadingPages.contains(pageID) else {
return
}
// must have data
guard let response = result.value else {
completion?(.failure(ActivityError.noData))
return
}
// map data into page
guard let page = strongSelf.process(response: response, pageID: pageID) else {
completion?(.failure(ActivityError.notParsable))
return
}
strongSelf.pendingRequestsList.add(page: page)
completion?(.success(page.items))
service.loadPendingsRequests(
cursor: followersList.cursor,
limit: followersList.limit) { [weak self] (result: Result<FeedResponseUserCompactView>) in
defer {
loadingPages.remove(pageID)
}
// exit on released or canceled
guard let strongSelf = self, strongSelf.loadingPages.contains(pageID) else {
return
}
// must have data
guard let response = result.value else {
completion?(.failure(ActivityError.noData))
return
}
// map data into page
guard let page = strongSelf.process(response: response, pageID: pageID) else {
completion?(.failure(ActivityError.notParsable))
return
}
strongSelf.pendingRequestsList.add(page: page)
completion?(.success(page.items))
}
}

Просмотреть файл

@ -1,16 +1,16 @@
{
"data": [
{
"activityHandle": "3suP7b3FuDn",
"createdTime": "2017-09-15T12:20:42.7438412Z",
"activityHandle": "3shxpwwGpMH",
"createdTime": "2017-09-20T08:18:48.8390341Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
@ -26,10 +26,10 @@
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DvIJuF9h",
"parentHandle": "3uhmhFecuY2",
"contentHandle": "3sjLwVd5s7S",
"parentHandle": "3uhkWMemLBe",
"rootHandle": null,
"text": "Пджавлджплвджлпджал ",
"text": "15",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
@ -46,16 +46,61 @@
}
},
{
"activityHandle": "3suPFBj38MT",
"createdTime": "2017-09-15T12:19:40.5778012Z",
"activityHandle": "3shxrN0P7Zb",
"createdTime": "2017-09-20T08:18:37.1817906Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3sjLwVd5s7S",
"parentHandle": "3uhkWMemLBe",
"rootHandle": null,
"text": "15",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3shxvcT99QT",
"createdTime": "2017-09-20T08:18:02.307599Z",
"activityType": "Comment",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
@ -71,10 +116,10 @@
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3uhmhFecuY2",
"contentHandle": "3uhkWMemLBe",
"parentHandle": null,
"rootHandle": null,
"text": "test",
"text": "test 1",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
@ -91,188 +136,8 @@
}
},
{
"activityHandle": "3suR89TWpAi",
"createdTime": "2017-09-15T12:03:09.6342209Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3suRO5TyYsJ",
"parentHandle": "3suRRiJZa5x",
"rootHandle": null,
"text": "Comment 1",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3suRL5VwlLM",
"createdTime": "2017-09-15T12:01:23.6462078Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3suRO5TyYsJ",
"parentHandle": "3suRRiJZa5x",
"rootHandle": null,
"text": "Comment 1",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3suRO5TyYsJ",
"createdTime": "2017-09-15T12:00:59.0740321Z",
"activityType": "Comment",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3suRRiJZa5x",
"parentHandle": null,
"rootHandle": null,
"text": "Cache post",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3suRnAaXT5Z",
"createdTime": "2017-09-15T11:57:25.426066Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sudX8dh6Pe",
"createdTime": "2017-09-15T10:06:09.1968745Z",
"activityHandle": "3sjLvLVarKY",
"createdTime": "2017-09-19T19:20:22.9745832Z",
"activityType": "Comment",
"actorUsers": [
{
@ -286,65 +151,20 @@
}
],
"actedOnUser": {
"userHandle": "3tL16aGdz0x",
"firstName": "Igor",
"lastName": "Popov",
"photoHandle": "----8mg3EZz-cca2af74-a15a-4dd0-846d-6a7e28083bbf",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8mg3EZz-cca2af74-a15a-4dd0-846d-6a7e28083bbf",
"visibility": "Public",
"followerStatus": "None"
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3t1RMhHLmPj",
"parentHandle": null,
"rootHandle": null,
"text": "investors are not buying",
"blobType": "Image",
"blobHandle": "----8m3sjsO-91e15a50-ce27-4335-9d97-246903b57d54",
"blobUrl": "https://sp-ppe.azureedge.net/images/----8m3sjsO-91e15a50-ce27-4335-9d97-246903b57d54"
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3swqD7ZSAL5",
"createdTime": "2017-09-14T13:36:48.5673247Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"userHandle": "3vasrlAHhYf",
"firstName": "Oleg",
"lastName": "Rezhko",
"photoHandle": "null",
"photoUrl": "https://sp-ppe.azureedge.net/images/null",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3swqTx9ahvt",
"parentHandle": "3swr3Rgw6Qa",
"contentType": "Topic",
"contentHandle": "3uhkWMemLBe",
"parentHandle": null,
"rootHandle": null,
"text": "~!@#$%^&*()_+}{:\"?><>",
"text": "test 1",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
@ -361,485 +181,35 @@
}
},
{
"activityHandle": "3swqIHJVWDO",
"createdTime": "2017-09-14T13:36:06.358318Z",
"activityType": "Like",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3swr3Rgw6Qa",
"parentHandle": null,
"rootHandle": null,
"text": "тест",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3swqTx9ahvt",
"createdTime": "2017-09-14T13:34:30.7626601Z",
"activityHandle": "3sjLwVd5s7S",
"createdTime": "2017-09-19T19:20:13.4850261Z",
"activityType": "Comment",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"userHandle": "3vasrlAHhYf",
"firstName": "Oleg",
"lastName": "Rezhko",
"photoHandle": "null",
"photoUrl": "https://sp-ppe.azureedge.net/images/null",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3swr3Rgw6Qa",
"contentHandle": "3uhkWMemLBe",
"parentHandle": null,
"rootHandle": null,
"text": "тест",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3swrHT1OKT6",
"createdTime": "2017-09-14T13:27:28.7633922Z",
"activityType": "Comment",
"actorUsers": [
{
"userHandle": "3ui66fSIueT",
"firstName": "Alanxxx",
"lastName": "Poexxx",
"photoHandle": "----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"photoUrl": "https://sp-ppe.azureedge.net/images/----8los_c1-b85e4d20-734e-4880-b020-f6a0cbbec557",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3vC_QIk24au",
"firstName": "Igor",
"lastName": "Akvelon",
"photoHandle": null,
"photoUrl": null,
"visibility": "Private",
"followerStatus": "None"
},
"actedOnContent": {
"contentType": "Topic",
"contentHandle": "3t--H6O0DvS",
"parentHandle": null,
"rootHandle": null,
"text": "Bxbxbd",
"blobType": "Image",
"blobHandle": "----8m--ZNJ-005a744c-b735-4cc8-9f47-d7b5a5f5526d",
"blobUrl": "https://sp-ppe.azureedge.net/images/----8m--ZNJ-005a744c-b735-4cc8-9f47-d7b5a5f5526d"
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8VqhO2UQ",
"createdTime": "2017-09-14T10:48:13.7332316Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8WQXzdj3",
"createdTime": "2017-09-14T10:48:09.0186595Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8Wrs2JKE",
"createdTime": "2017-09-14T10:48:05.3912115Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8givdIRQ",
"createdTime": "2017-09-14T10:46:36.4247838Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8h4kaO2Z",
"createdTime": "2017-09-14T10:46:33.5022674Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8hTg-dFM",
"createdTime": "2017-09-14T10:46:30.3111172Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8hxsGY-U",
"createdTime": "2017-09-14T10:46:26.3192424Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
},
"totalActions": 1,
"unread": true,
"app": {
"name": "iOS SDK Dev",
"iconHandle": null,
"iconUrl": null,
"platformType": "IOS",
"deepLink": null,
"storeLink": null
}
},
{
"activityHandle": "3sx8jw_XKMI",
"createdTime": "2017-09-14T10:46:10.1008201Z",
"activityType": "Reply",
"actorUsers": [
{
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
}
],
"actedOnUser": {
"userHandle": "3v9gnzwILTS",
"firstName": "Alex",
"lastName": "Test",
"photoHandle": "67564D82-0A9C-4773-B4B2-3A81147BF878",
"photoUrl": "https://sp-ppe.azureedge.net/images/67564D82-0A9C-4773-B4B2-3A81147BF878",
"visibility": "Public",
"followerStatus": "Follow"
},
"actedOnContent": {
"contentType": "Comment",
"contentHandle": "3t1DyyaMKjr",
"parentHandle": "3uhmhFecuY2",
"rootHandle": null,
"text": "Sdfdsfssf",
"text": "test 1",
"blobType": "Unknown",
"blobHandle": null,
"blobUrl": null
@ -856,5 +226,5 @@
}
}
],
"cursor": "3sx8jw_XKMI"
"cursor": "3sjLwVd5s7S"
}

Просмотреть файл

@ -20,13 +20,80 @@ class ActivityEntitiesTests: XCTestCase {
// given
let service = Service()
let request: RequestBuilder<FeedResponseUserCompactView>? = service.builder(cursor: "safa", limit: 10)
let a = 1
// let _: RequestBuilder<FeedResponseUserCompactView>? = service.builder(cursor: "safa", limit: 10)
}
func testThatServiceProducesResponse() {
let service = ActivityServiceMock()
let response = buildActivitiResponseMock()
service.followingActivitiesResponse = .success(response)
let e = expectation(description: #file)
service.loadFollowingActivities(cursor: "", limit: 10) { (result: Result<FeedResponseActivityView> ) in
XCTAssertTrue(result.isSuccess)
e.fulfill()
}
waitForExpectations(timeout: 1, handler: nil)
}
func testThatInteractorFetchesResult() {
// given
let service = ActivityServiceMock()
let pendingRequestsResponse = buildPendingRequestsResponseMock()
let followingActivitiesResponse = buildActivitiResponseMock()
service.pendingRequestsResponse = .success(pendingRequestsResponse)
service.followingActivitiesResponse = .success(followingActivitiesResponse)
let interactor = ActivityInteractor()
interactor.service = service
let pendingRequests = expectation(description: #file)
// when #1
interactor.loadNextPagePendigRequestItems { (result) in
// then #1
guard let items = result.value else {
XCTFail()
return
}
XCTAssertTrue(items.count == pendingRequestsResponse.data?.count)
pendingRequests.fulfill()
}
let followingActivities = expectation(description: #file)
// when #2
interactor.loadNextPageFollowingActivities { (result) in
// then #2
guard let items = result.value else {
XCTFail()
return
}
XCTAssertTrue(items.count == followingActivitiesResponse.data?.count)
followingActivities.fulfill()
}
waitForExpectations(timeout: 1, handler: nil)
}
func buildActivitiResponseMock() -> FeedResponseActivityView {
return FeedResponseActivityView().mockResponse()
}
func buildPendingRequestsResponseMock() -> FeedResponseUserCompactView {
return FeedResponseUserCompactView().mockResponse()
}
}