/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.instagram.common.json.annotation.processor

import org.junit.Assert.assertEquals
import org.junit.Test

/**
 * Testing whether the [JsonAnnotationProcessor] generates valid Java code when reading annotations
 * of larger models
 */
class JavaLargeObjectSupportTest {

  val json =
      """{"field1":"field1","field2":"field2","field3":"field3","field4":"field4","field5":"field5","field6":"field6","field7":"field7","field8":"field8","field9":"field9","field10":"field10","field11":"field11","field12":"field12","field13":"field13","field14":"field14","field15":"field15","field16":"field16","field17":"field17","field18":"field18","field19":"field19","field20":"field20","field21":"field21","field22":"field22","field23":"field23","field24":"field24","field25":"field25","field26":"field26","field27":"field27","field28":"field28","field29":"field29","field30":"field30","field31":"field31","field32":"field32","field33":"field33","field34":"field34","field35":"field35","field36":"field36","field37":"field37","field38":"field38","field39":"field39","field40":"field40","field41":"field41","field42":"field42","field43":"field43","field44":"field44","field45":"field45","field46":"field46","field47":"field47","field48":"field48","field49":"field49","field50":"field50","field51":"field51","field52":"field52","field53":"field53","field54":"field54","field55":"field55","field56":"field56","field57":"field57","field58":"field58","field59":"field59","field60":"field60","field61":"field61","field62":"field62","field63":"field63","field64":"field64","field65":"field65","field66":"field66","field67":"field67","field68":"field68","field69":"field69","field70":"field70","field71":"field71","field72":"field72","field73":"field73","field74":"field74","field75":"field75","field76":"field76","field77":"field77","field78":"field78","field79":"field79","field80":"field80","field81":"field81","field82":"field82","field83":"field83","field84":"field84","field85":"field85","field86":"field86","field87":"field87","field88":"field88","field89":"field89","field90":"field90","field91":"field91","field92":"field92","field93":"field93","field94":"field94","field95":"field95","field96":"field96","field97":"field97","field98":"field98","field99":"field99","field100":"field100","field101":"field101","field102":"field102","field103":"field103","field104":"field104","field105":"field105","field106":"field106","field107":"field107","field108":"field108","field109":"field109","field110":"field110","field111":"field111","field112":"field112","field113":"field113","field114":"field114","field115":"field115","field116":"field116","field117":"field117","field118":"field118","field119":"field119","field120":"field120","field121":"field121","field122":"field122","field123":"field123","field124":"field124","field125":"field125","field126":"field126","field127":"field127","field128":"field128","field129":"field129","field130":"field130","field131":"field131","field132":"field132","field133":"field133","field134":"field134","field135":"field135","field136":"field136","field137":"field137","field138":"field138","field139":"field139","field140":"field140","field141":"field141","field142":"field142","field143":"field143","field144":"field144","field145":"field145","field146":"field146","field147":"field147","field148":"field148","field149":"field149","field150":"field150","field151":"field151","field152":"field152","field153":"field153","field154":"field154","field155":"field155","field156":"field156","field157":"field157","field158":"field158","field159":"field159","field160":"field160","field161":"field161","field162":"field162","field163":"field163","field164":"field164","field165":"field165","field166":"field166","field167":"field167","field168":"field168","field169":"field169","field170":"field170","field171":"field171","field172":"field172","field173":"field173","field174":"field174","field175":"field175","field176":"field176","field177":"field177","field178":"field178","field179":"field179","field180":"field180","field181":"field181","field182":"field182","field183":"field183","field184":"field184","field185":"field185","field186":"field186","field187":"field187","field188":"field188","field189":"field189","field190":"field190","field191":"field191","field192":"field192","field193":"field193","field194":"field194","field195":"field195","field196":"field196","field197":"field197","field198":"field198","field199":"field199","field200":"field200","field201":"field201","field202":"field202","field203":"field203","field204":"field204","field205":"field205","field206":"field206","field207":"field207","field208":"field208","field209":"field209","field210":"field210","field211":"field211","field212":"field212","field213":"field213","field214":"field214","field215":"field215","field216":"field216","field217":"field217","field218":"field218","field219":"field219","field220":"field220","field221":"field221","field222":"field222","field223":"field223","field224":"field224","field225":"field225","field226":"field226","field227":"field227","field228":"field228","field229":"field229","field230":"field230","field231":"field231","field232":"field232","field233":"field233","field234":"field234","field235":"field235","field236":"field236","field237":"field237","field238":"field238","field239":"field239","field240":"field240","field241":"field241","field242":"field242","field243":"field243","field244":"field244","field245":"field245","field246":"field246","field247":"field247","field248":"field248","field249":"field249","field250":"field250","field251":"field251","field252":"field252","field253":"field253","field254":"field254","field255":"field255","field256":"field256","field257":"field257","field258":"field258","field259":"field259","field260":"field260","field261":"field261","field262":"field262","field263":"field263","field264":"field264","field265":"field265","field266":"field266","field267":"field267","field268":"field268","field269":"field269","field270":"field270","field271":"field271","field272":"field272","field273":"field273","field274":"field274","field275":"field275","field276":"field276","field277":"field277","field278":"field278","field279":"field279","field280":"field280","field281":"field281","field282":"field282","field283":"field283","field284":"field284","field285":"field285","field286":"field286","field287":"field287","field288":"field288","field289":"field289","field290":"field290","field291":"field291","field292":"field292","field293":"field293","field294":"field294","field295":"field295","field296":"field296","field297":"field297","field298":"field298","field299":"field299","field300":"field300","field301":"field301","field302":"field302","field303":"field303","field304":"field304","field305":"field305","field306":"field306","field307":"field307","field308":"field308","field309":"field309","field310":"field310","field311":"field311","field312":"field312","field313":"field313","field314":"field314","field315":"field315","field316":"field316","field317":"field317","field318":"field318","field319":"field319","field320":"field320","field321":"field321","field322":"field322","field323":"field323","field324":"field324","field325":"field325","field326":"field326","field327":"field327","field328":"field328","field329":"field329","field330":"field330","field331":"field331","field332":"field332","field333":"field333","field334":"field334","field335":"field335","field336":"field336","field337":"field337","field338":"field338","field339":"field339","field340":"field340","field341":"field341","field342":"field342","field343":"field343","field344":"field344","field345":"field345","field346":"field346","field347":"field347","field348":"field348","field349":"field349","field350":"field350","field351":"field351","field352":"field352","field353":"field353","field354":"field354","field355":"field355","field356":"field356","field357":"field357","field358":"field358","field359":"field359","field360":"field360","field361":"field361","field362":"field362","field363":"field363","field364":"field364","field365":"field365","field366":"field366","field367":"field367","field368":"field368","field369":"field369","field370":"field370","field371":"field371","field372":"field372","field373":"field373","field374":"field374","field375":"field375","field376":"field376","field377":"field377","field378":"field378","field379":"field379","field380":"field380","field381":"field381","field382":"field382","field383":"field383","field384":"field384","field385":"field385","field386":"field386","field387":"field387","field388":"field388","field389":"field389","field390":"field390","field391":"field391","field392":"field392","field393":"field393","field394":"field394","field395":"field395","field396":"field396","field397":"field397","field398":"field398","field399":"field399","field400":"field400","field401":"field401","field402":"field402","field403":"field403","field404":"field404","field405":"field405","field406":"field406","field407":"field407","field408":"field408","field409":"field409","field410":"field410","field411":"field411","field412":"field412","field413":"field413","field414":"field414","field415":"field415","field416":"field416","field417":"field417","field418":"field418","field419":"field419","field420":"field420","field421":"field421","field422":"field422","field423":"field423","field424":"field424","field425":"field425","field426":"field426","field427":"field427","field428":"field428","field429":"field429","field430":"field430","field431":"field431","field432":"field432","field433":"field433","field434":"field434","field435":"field435","field436":"field436","field437":"field437","field438":"field438","field439":"field439","field440":"field440","field441":"field441","field442":"field442","field443":"field443","field444":"field444","field445":"field445","field446":"field446","field447":"field447","field448":"field448","field449":"field449","field450":"field450","field451":"field451","field452":"field452","field453":"field453","field454":"field454","field455":"field455","field456":"field456","field457":"field457","field458":"field458","field459":"field459","field460":"field460","field461":"field461","field462":"field462","field463":"field463","field464":"field464","field465":"field465","field466":"field466","field467":"field467","field468":"field468","field469":"field469","field470":"field470","field471":"field471","field472":"field472","field473":"field473","field474":"field474","field475":"field475","field476":"field476","field477":"field477","field478":"field478","field479":"field479","field480":"field480","field481":"field481","field482":"field482","field483":"field483","field484":"field484","field485":"field485","field486":"field486","field487":"field487","field488":"field488","field489":"field489","field490":"field490","field491":"field491","field492":"field492","field493":"field493","field494":"field494","field495":"field495","field496":"field496","field497":"field497","field498":"field498","field499":"field499","field500":"field500","field501":"field501","field502":"field502","field503":"field503","field504":"field504","field505":"field505","field506":"field506","field507":"field507","field508":"field508"}"""

  @Test
  fun handlesJavaImmutableClassFromJson() {
    val actual = LargeObject__JsonHelper.parseFromJson(json)
    assertEquals("field1", actual.field1)
    assertEquals("field508", actual.field508)
  }

  @Test
  fun deserializeThenSerializeIsSymmetric() {
    val actual = LargeObject__JsonHelper.parseFromJson(json)
    val actualJson = LargeObject__JsonHelper.serializeToJson(actual)

    assertEquals(actualJson, json)
  }
}
