diff --git a/bloc/pom.xml b/bloc/pom.xml index eeaef8c8cae2..bde50b5daf5c 100644 --- a/bloc/pom.xml +++ b/bloc/pom.xml @@ -1,4 +1,30 @@ + diff --git a/bloc/src/main/java/com/iluwatar/bloc/Bloc.java b/bloc/src/main/java/com/iluwatar/bloc/Bloc.java index caed7080ab1c..47a85b8f2804 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/Bloc.java +++ b/bloc/src/main/java/com/iluwatar/bloc/Bloc.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import java.util.ArrayList; diff --git a/bloc/src/main/java/com/iluwatar/bloc/BlocUi.java b/bloc/src/main/java/com/iluwatar/bloc/BlocUi.java index e74536c10c40..1d0f706ecf2d 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/BlocUi.java +++ b/bloc/src/main/java/com/iluwatar/bloc/BlocUi.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import java.awt.BorderLayout; diff --git a/bloc/src/main/java/com/iluwatar/bloc/ListenerManager.java b/bloc/src/main/java/com/iluwatar/bloc/ListenerManager.java index 66caeddafea0..ca4c5ff2201d 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/ListenerManager.java +++ b/bloc/src/main/java/com/iluwatar/bloc/ListenerManager.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import java.util.List; diff --git a/bloc/src/main/java/com/iluwatar/bloc/Main.java b/bloc/src/main/java/com/iluwatar/bloc/Main.java index 1499e6211e56..5dae30ed524e 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/Main.java +++ b/bloc/src/main/java/com/iluwatar/bloc/Main.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; /** diff --git a/bloc/src/main/java/com/iluwatar/bloc/State.java b/bloc/src/main/java/com/iluwatar/bloc/State.java index 5e184d2af20b..9a08b3df7867 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/State.java +++ b/bloc/src/main/java/com/iluwatar/bloc/State.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; /** diff --git a/bloc/src/main/java/com/iluwatar/bloc/StateListener.java b/bloc/src/main/java/com/iluwatar/bloc/StateListener.java index 49527441eedb..f656b3f3dee5 100644 --- a/bloc/src/main/java/com/iluwatar/bloc/StateListener.java +++ b/bloc/src/main/java/com/iluwatar/bloc/StateListener.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; /** diff --git a/bloc/src/test/java/com/iluwatar/bloc/BlocTest.java b/bloc/src/test/java/com/iluwatar/bloc/BlocTest.java index 26821366401e..bde72d6ddce0 100644 --- a/bloc/src/test/java/com/iluwatar/bloc/BlocTest.java +++ b/bloc/src/test/java/com/iluwatar/bloc/BlocTest.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/bloc/src/test/java/com/iluwatar/bloc/BlocUiTest.java b/bloc/src/test/java/com/iluwatar/bloc/BlocUiTest.java index 7b793f89461a..35f4c9c6baf7 100644 --- a/bloc/src/test/java/com/iluwatar/bloc/BlocUiTest.java +++ b/bloc/src/test/java/com/iluwatar/bloc/BlocUiTest.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import org.junit.After; diff --git a/bloc/src/test/java/com/iluwatar/bloc/MainTest.java b/bloc/src/test/java/com/iluwatar/bloc/MainTest.java index b8d1b0c70ca4..ba34828b83c4 100644 --- a/bloc/src/test/java/com/iluwatar/bloc/MainTest.java +++ b/bloc/src/test/java/com/iluwatar/bloc/MainTest.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.bloc; import org.junit.jupiter.api.Test; diff --git a/etl/etc/etl.urm.puml b/etl/etc/etl.urm.puml new file mode 100644 index 000000000000..02af47ddf261 --- /dev/null +++ b/etl/etc/etl.urm.puml @@ -0,0 +1,2 @@ +@startuml +@enduml \ No newline at end of file diff --git a/etl/pom.xml b/etl/pom.xml new file mode 100644 index 000000000000..da799ae1228b --- /dev/null +++ b/etl/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + com.iluwatar + java-design-patterns + 1.26.0-SNAPSHOT + + etl + + + org.json + json + 20240303 + + + javax.json + javax.json-api + + + org.glassfish + javax.json + 1.1 + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + src/main/resources + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + + + com.iluwatar.command.App + + + + + + + + + diff --git a/etl/src/main/java/com/iluwatar/etl/App.java b/etl/src/main/java/com/iluwatar/etl/App.java new file mode 100644 index 000000000000..8c148ec00122 --- /dev/null +++ b/etl/src/main/java/com/iluwatar/etl/App.java @@ -0,0 +1,55 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package com.iluwatar.etl; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; + +/** + * The ETL pattern is a ... + */ +public class App { + + /** + * Program entry point. + * + * @param args command line args + */ + public static void main(String[] args) { + var extract = new Extract(); + var transform = new Transform(); + + + try { + List> result = extract.extract(); + transform.transform(result); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/etl/src/main/java/com/iluwatar/etl/Extract.java b/etl/src/main/java/com/iluwatar/etl/Extract.java new file mode 100644 index 000000000000..5c060508ac00 --- /dev/null +++ b/etl/src/main/java/com/iluwatar/etl/Extract.java @@ -0,0 +1,44 @@ +package com.iluwatar.etl; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Extract { + + public List> extract() throws IOException { + URL resourceUrl = getClass().getClassLoader().getResource("SocialMediaTop100.csv"); + + List> result = new ArrayList<>(); + + if (resourceUrl != null) { + InputStream is = resourceUrl.openStream(); + result = convert(is); + + } else { + System.out.println("Resource not found"); + } + + return result; + } + + public static List> convert(InputStream inputStream) throws IOException { + List> result = new ArrayList<>(); + + try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = br.readLine()) != null) { + String[] values = line.split(","); // Assuming comma-separated values + result.add(Arrays.asList(values)); + } + } + + return result; + } + +} diff --git a/etl/src/main/java/com/iluwatar/etl/Transform.java b/etl/src/main/java/com/iluwatar/etl/Transform.java new file mode 100644 index 000000000000..12fe43efb76f --- /dev/null +++ b/etl/src/main/java/com/iluwatar/etl/Transform.java @@ -0,0 +1,118 @@ +package com.iluwatar.etl; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.json.Json; +import javax.json.JsonArrayBuilder; +import javax.json.JsonObject; +import javax.json.JsonObjectBuilder; + +/** + * */ +public class Transform { + + public void transform(List> lines) throws IOException { + + lines.remove(0); + + JsonObject json = createPersonsJSON(lines); + // Get the path to the resources folder + Path resourceDirectory = Paths.get("target"); + Path filePath = resourceDirectory.resolve("output.txt"); + + // Write the string to the file + Path path = Files.writeString(filePath, json.toString(), StandardCharsets.UTF_8); + System.out.println("File written successfully at" + path.toString()); + } + + private static Map>> createPersonMap(List> lines) { + Map>> namedMap = new HashMap(); + lines.stream().forEach(list -> { + String key = list.get(1); + if(namedMap.containsKey(key)) { + List> values = namedMap.get(key); + values.add(list); + namedMap.put(key, values); + } else { + List> values = new ArrayList(); + values.add(list); + namedMap.put(key, values); + } + + }); + + return namedMap; + } + + private static JsonObject createPersonsJSON(List> lines) { + Map>> namedMap = createPersonMap(lines); + + JsonArrayBuilder outerPersonsBuilder = Json.createArrayBuilder(); + + namedMap.entrySet().forEach(person -> + outerPersonsBuilder.add(createPersonBuilder(person))); + + return Json.createObjectBuilder().add("persons", outerPersonsBuilder).build() ; + + } + + private static JsonObjectBuilder createPersonBuilder(Entry>> person) { + + JsonArrayBuilder outerPersonBuilder = Json.createArrayBuilder(); + + JsonObjectBuilder nameBuilder = Json.createObjectBuilder() + .add("name", person.getKey()); + + JsonArrayBuilder outerMediaBuilder = createMediaBuilder(person); + JsonObjectBuilder mediaBuilder = Json.createObjectBuilder() + .add("media", outerMediaBuilder); + + outerPersonBuilder.add(nameBuilder).add(mediaBuilder); + return Json.createObjectBuilder().add("person", outerPersonBuilder); + + } + + private static JsonArrayBuilder createMediaBuilder(Entry>> person) { + JsonArrayBuilder outerMediaBuilder = Json.createArrayBuilder(); + + person.getValue().forEach(medium -> { + if(medium.contains("Twitter")) + outerMediaBuilder.add(createMediumBuilder(medium, "Twitter")); + if(medium.contains("Instagram")) + outerMediaBuilder.add(createMediumBuilder(medium, "Instagram")); + if(medium.contains("TikTok")) + outerMediaBuilder.add(createMediumBuilder(medium, "TikTok")); + if(medium.contains("Twitch")) + outerMediaBuilder.add(createMediumBuilder(medium, "Twitch")); + if(medium.contains("YouTube")) + outerMediaBuilder.add(createMediumBuilder(medium, "YouTube")); + }); + + return outerMediaBuilder; + } + + private static JsonObjectBuilder createMediumBuilder(List medium, String mediumName) { + + JsonObjectBuilder postsBuilder = Json.createObjectBuilder() + .add("posts", medium.get(3)); + JsonObjectBuilder followerBuilder = Json.createObjectBuilder() + .add("followers", medium.get(2)); + + JsonArrayBuilder outerBuilder = Json.createArrayBuilder() + .add(postsBuilder).add(followerBuilder); + return Json.createObjectBuilder().add(mediumName,outerBuilder); + + } + + +} diff --git a/etl/src/main/resources/SocialMediaTop100.csv b/etl/src/main/resources/SocialMediaTop100.csv new file mode 100644 index 000000000000..3e232a1e7ee3 --- /dev/null +++ b/etl/src/main/resources/SocialMediaTop100.csv @@ -0,0 +1,501 @@ +N,PROFILE,FOLLOWERS,POSTS,Platform +1,Instagram ,539446645,7202,Instagram  +2,Cristiano Ronaldo ,473864939,3338,Instagram  +3,Kylie  ,364542529,6935,Instagram  +4,Leo Messi ,355790796,890,Instagram  +5,Selena Gomez ,341579063,1828,Instagram  +6,Dwayne Johnson ,333221596,6738,Instagram  +7,Kim Kardashian ,328323322,5598,Instagram  +8,Ariana Grande ,326473270,4963,Instagram  +9,Beyonce´ ,272211534,2037,Instagram  +10,Khloe´ Kardashian ,267912338,4104,Instagram  +11,Justin Bieber ,253285832,7330,Instagram  +12,Kendall ,252632221,674,Instagram  +13,National Geographic ,236500488,27045,Instagram  +14,Nike ,233371786,948,Instagram  +15,Taylor Swift ,221732794,536,Instagram  +16,Jennifer Lopez ,220169794,3126,Instagram  +17,Virat Kohli ,211074078,1405,Instagram  +18,Barbie ,201394982,6343,Instagram  +19,Kourtney Kardashian Barker  ,194512673,4352,Instagram  +20,Miley Cyrus ,180959274,1181,Instagram  +21,NJ  ,176935982,5271,Instagram  +22,KATY PERRY ,169597869,2047,Instagram  +23,Kevin Hart ,151581146,8211,Instagram  +24,Zendaya ,150280418,3540,Instagram  +25,Demi Lovato ,138781881,47,Instagram  +26,badgalriri ,135053892,4837,Instagram  +27, ,130398630,2344,Instagram  +28,Ellen DeGeneres ,124943799,10549,Instagram  +29,Real Madrid C.F. ,123177126,6815,Instagram  +30,champagnepapi ,119117889,5212,Instagram  +31,BREEZY ,117994690,7322,Instagram  +32,FC Barcelona ,111257233,16952,Instagram  +33,BILLIE EILISH ,105134435,695,Instagram  +34,UEFA Champions League ,96634213,17942,Instagram  +35,DUA LIPA ,85756579,1259,Instagram  +36,Gal Gadot ,85305143,1684,Instagram  +37,Vin Diesel ,82187552,1824,Instagram  +38,NASA ,81215401,3563,Instagram  +39,Priyanka ,80986405,3530,Instagram  +40,LISA ,80723426,868,Instagram  +41,Khaby Lame ,78697857,291,Instagram  +42,Shakira ,76041310,1989,Instagram  +43,snoopdogg ,75284700,54207,Instagram  +44,Gigi Hadid ,75207736,3253,Instagram  +45,David Beckham ,74912255,1537,Instagram  +46,Shraddha  ,73878089,1875,Instagram  +47,Victoria's Secret ,73190174,2861,Instagram  +48,Kylian Mbappe´ ,72705315,1155,Instagram  +49,Neha Kakkar (Mrs. Singh) ,70404564,2286,Instagram  +50,NBA ,69922564,50977,Instagram  +51,Shawn Mendes ,69887832,2534,Instagram  +52,Narendra Modi ,68816270,540,Instagram  +53,J ,68733032,860,Instagram  +54,Alia Bhatt  ,68517743,1833,Instagram  +55,Deepika Padukone ,68295084,275,Instagram  +56,Tom Holland ,67722305,1218,Instagram  +57,Ronaldo de Assis Moreira ,67646939,2959,Instagram  +58,Emma Watson ,67296368,345,Instagram  +59,BTS official ,66769961,1092,Instagram  +60,Katrina Kaif ,66186703,1005,Instagram  +61,Marvel Entertainment ,66083072,7055,Instagram  +62,Justin Timberlake ,65817755,784,Instagram  +63,camila ,64887038,2888,Instagram  +64,Will Smith ,63991832,1365,Instagram  +65,Raffi Ahmad and Nagita Slavina ,63437657,17509,Instagram  +66,Anitta  ,63122857,5135,Instagram  +67,MALUMA ,62858032,8135,Instagram  +68,Akshay Kumar ,62777257,1881,Instagram  +69,JISOO ,62683010,829,Instagram  +70,Jacqueline Fernandez ,62637438,2443,Instagram  +71,Paris Saint-Germain ,61860116,9867,Instagram  +72,ROSE´ ,61660597,818,Instagram  +73,Manchester United ,59520626,22777,Instagram  +74,AnushkaSharma1588 ,59477707,1165,Instagram  +75,Whindersson Nunes ,58718833,2734,Instagram  +76,Premier League ,58541952,19991,Instagram  +77,9GAG: Go Fun The World ,58125945,30005,Instagram  +78,Marcelo Vieira ,57970008,2695,Instagram  +79,Millie Bobby Brown ,57350069,299,Instagram  +80,Karim Benzema ,56760930,2023,Instagram  +81,Chris Hemsworth ,55866652,851,Instagram  +82,KAROL G ,55413300,3296,Instagram  +83,Paul Labile Pogba ,55138512,1302,Instagram  +84,Zlatan Ibrahimovic ,55048835,875,Instagram  +85,Leonardo DiCaprio ,54518260,1689,Instagram  +86,Juventus ,54472637,12633,Instagram  +87,Zac Efron ,54434089,666,Instagram  +88,Bella  ,54034924,3152,Instagram  +89,Urvashi Rautela ,53812411,3396,Instagram  +90,Tata Werneck ,53806580,5583,Instagram  +91,Salman Khan ,53372896,1176,Instagram  +92,Robert Downey Jr. Official ,53368184,425,Instagram  +93,Sunny Leone ,53326932,4575,Instagram  +94,Lady Gaga ,53211167,3559,Instagram  +95,disha patani (paatni)  ,52855261,2137,Instagram  +96,J Balvin ,52776655,13063,Instagram  +97,Sergio Ramos ,52708281,2228,Instagram  +98,ZARA Official ,52498150,3756,Instagram  +99,Mohamed Salah ,52422831,841,Instagram  +100,Ayu Tingting ,52386780,11300,Instagram  +1,Barack Obama ,132473746,16563,Twitter +2,Justin Bieber ,114165664,31371,Twitter +3,KATY PERRY ,108950737,11715,Twitter +4,Rihanna ,106989611,10632,Twitter +5,Elon Musk ,102819963,18921,Twitter +6,Cristiano Ronaldo ,102672739,3808,Twitter +7,Taylor Swift ,90814615,720,Twitter +8,Lady Gaga ,84876972,9919,Twitter +9,Narendra Modi ,81398641,33650,Twitter +10,Ellen DeGeneres ,77430041,24074,Twitter +11,YouTube ,75884044,46030,Twitter +12,Kim Kardashian ,73264301,35699,Twitter +13,Selena Gomez ,66143411,5429,Twitter +14,CNN Breaking News ,63606552,78179,Twitter +15,Justin Timberlake ,63088413,4365,Twitter +16,Twitter ,62416599,15015,Twitter +17,NASA ,60698510,68350,Twitter +18,Bill Gates ,60153943,4003,Twitter +19,Neymar Jr ,57484730,42222,Twitter +20,Britney Spears ,55869666,5636,Twitter +21,Demi Lovato ,54190632,17802,Twitter +22,The New York Times ,53825679,480222,Twitter +23,Shakira ,53235721,7908,Twitter +24,LeBron James ,51947180,8571,Twitter +25,Fallon.eth ,51337983,14172,Twitter +26,BBC Breaking News ,50664033,38173,Twitter +27,PMO India ,49814762,32546,Twitter +28,Virat Kohli ,49308402,2655,Twitter +29,Amitabh Bachchan ,47764001,69352,Twitter +30, ,46979565,12895,Twitter +31,Miley Cyrus ,46816418,12116,Twitter +32,Akshay Kumar ,45132749,41372,Twitter +33,Salman Khan ,44236663,43151,Twitter +34,Real Madrid C.F. ,43764644,83921,Twitter +35,Bruno Mars ,43294761,4957,Twitter +36,Oprah Winfrey ,43289835,13580,Twitter +37,FC Barcelona ,43089932,125678,Twitter +38,Shah Rukh Khan ,42638106,58295,Twitter +39,Niall Horan ,41256634,18359,Twitter +40,ESPN ,41229434,131699,Twitter +41,BTS_official ,40593716,10346,Twitter +42,Kylie Jenner ,40175615,14275,Twitter +43,Drizzy ,39703326,1805,Twitter +44,Harry Styles. ,38100188,5650,Twitter +45,BBC News (World) ,37706985,349709,Twitter +46,Sachin Tendulkar ,37631088,4720,Twitter +47,Kevin Hart ,37470813,41859,Twitter +48,Wiz Khalifa ,36666230,50423,Twitter +49,Louis Tomlinson ,36040239,7634,Twitter +50,Lil Wayne WEEZY F ,35027433,2498,Twitter +51,Joe Biden ,34912026,8371,Twitter +52,Liam ,34477634,11685,Twitter +53,Premier League ,34315514,140809,Twitter +54,Instagram ,33915351,15094,Twitter +55,Kendall ,32357505,9657,Twitter +56,Manchester United ,32211336,75684,Twitter +57,Chris Brown ,32198251,4646,Twitter +58,Hrithik Roshan ,31886135,6035,Twitter +59,P!nk ,31666168,8214,Twitter +60,Hillary Clinton ,31615951,13548,Twitter +61,One Direction ,31142763,9754,Twitter +62,zayn ,31040206,3690,Twitter +63,ye ,30823235,1909,Twitter +64,Amit Shah ,30381411,17092,Twitter +65,Khloé ,30279252,67561,Twitter +66,Alicia Keys ,30110837,10867,Twitter +67,Kaka ,29383091,5298,Twitter +68,Emma Watson ,28658991,1853,Twitter +69,Conan O'Brien ,28581073,5211,Twitter +70,National Geographic ,28016531,67046,Twitter +71,PRIYANKA ,27790361,22254,Twitter +72,Adele ,27647371,368,Twitter +73,Deepika Padukone ,27438545,665,Twitter +74,The Economist ,26853411,314249,Twitter +75,Shawn Mendes ,26753615,15465,Twitter +76,Kourtney Kardashian ,26740551,14385,Twitter +77,Google ,26422157,164650,Twitter +78,PlayStation ,26347317,40926,Twitter +79,BIGHIT MUSIC ,26166689,8513,Twitter +80,Arvind Kejriwal ,26014305,33104,Twitter +81,Nicki Minaj ,25647776,43401,Twitter +82,Andrés Iniesta ,25484080,3343,Twitter +83,Reuters ,25458860,892566,Twitter +84,President Biden ,24387765,3691,Twitter +85,SpaceX ,24206586,6050,Twitter +86,A.R.Rahman ,24192262,6570,Twitter +87,Coldplay ,23602810,9322,Twitter +88,Anushka Sharma ,23161825,4702,Twitter +89,Virender Sehwag ,22917667,12244,Twitter +90,Marshall Mathers ,22766501,1187,Twitter +91,Fox News ,22215023,486592,Twitter +92,Michelle Obama ,22006755,1973,Twitter +93,Mariah Carey ,21819632,10671,Twitter +94,netflixbrasil ,21783674,73111,Twitter +95,Chelsea FC ,21692707,110222,Twitter +96,Alia Bhatt ,21562782,5575,Twitter +97,Rahul Gandhi ,21305498,6298,Twitter +98,Zendaya ,21154455,58368,Twitter +99,Ronaldinho ,20956217,6106,Twitter +100,Rohit Sharma ,20765073,2572,Twitter +1,T-Series,2.22E+08,17306,YouTube +2,Cocomelon - Nursery Rhymes,1.40E+08,786,YouTube +3,SET India,1.39E+08,91157,YouTube +4,PewDiePie,1.11E+08,4498,YouTube +5,MrBeast,1.01E+08,726,YouTube +6, Kids Diana Show,99600000,1008,YouTube +7,Like Nastya,99100000,701,YouTube +8,WWE,90100000,63027,YouTube +9,Zee Music Company,86600000,6569,YouTube +10,Vlad and Niki,84900000,472,YouTube +11,5-Minute Crafts,77100000,5575,YouTube +12,BLACKPINK,76100000,397,YouTube +13,Goldmines,73900000,3933,YouTube +14,Sony SAB,70500000,56189,YouTube +15,BANGTANTV,69900000,1787,YouTube +16,Justin Bieber,69700000,247,YouTube +17,HYBE LABELS,67800000,970,YouTube +18,Canal KondZilla,65900000,2312,YouTube +19,Zee TV,6.30E+07,60751,YouTube +20,Shemaroo Filmi Gaane,61300000,7873,YouTube +21,Pinkfong Baby Shark - Kids' Songs & Stories,59300000,2371,YouTube +22,Dude Perfect,58100000,297,YouTube +23,ChuChu TV Nursery Rhymes & Kids Songs,57700000,506,YouTube +24,Movieclips,57500000,39182,YouTube +25,Marshmello,55700000,401,YouTube +26,Colors TV,55100000,87220,YouTube +27,Wave Music,53400000,18617,YouTube +28,EminemMusic,5.30E+07,140,YouTube +29,Aaj Tak,52800000,195974,YouTube +30,Tips Official,52700000,3606,YouTube +31,Sony Music India,52400000,3179,YouTube +32,T-Series Bhakti Sagar,52400000,23856,YouTube +33,Ed Sheeran,52200000,252,YouTube +34,Ariana Grande,51600000,146,YouTube +35,LooLoo Kids - Nursery Rhymes and Children's Songs,49700000,552,YouTube +36,YRF,47500000,3286,YouTube +37,Taylor Swift,47100000,189,YouTube +38,JuegaGerman,46100000,1959,YouTube +39,Badabun,45600000,13775,YouTube +40,Infobells - Hindi,45500000,476,YouTube +41,Fernanfloo,45100000,541,YouTube +42,Felipe Neto,44300000,3507,YouTube +43,BRIGHT SIDE,43900000,4540,YouTube +44,whinderssonnunes,43900000,521,YouTube +45,Katy Perry,43200000,118,YouTube +46,Você Sabia?,43200000,1310,YouTube +47,Alan Walker,42200000,318,YouTube +48,Get Movies,41300000,3960,YouTube +49,A4,41200000,644,YouTube +50,ABS-CBN Entertainment,40500000,179359,YouTube +51,elrubiusOMG,40400000,705,YouTube +52,Rihanna,39500000,79,YouTube +53,Little Baby Bum - Nursery Rhymes & Kids Songs,39500000,1980,YouTube +54,Luisito Comunica,39200000,1119,YouTube +55, ,38700000,1196,YouTube +56,TheEllenShow,38300000,14402,YouTube +57,LUCCAS NETO - LUCCAS TOON,37800000,1875,YouTube +58,GR6 EXPLODE,37600000,4177,YouTube +59,One Direction,37400000,157,YouTube +60,Kimberly Loaiza,37200000,206,YouTube +61,Shakira,37100000,287,YouTube +62,Daddy Yankee,36800000,420,YouTube +63,CarryMinati,36200000,178,YouTube +64,Maroon 5,3.60E+07,163,YouTube +65,shfa2 - ,35800000,1348,YouTube +66,shfa,35800000,846,YouTube +67,TEDx Talks,35800000,185002,YouTube +68,Super Simple Songs - Kids Songs,35200000,600,YouTube +69,Masha and The Bear,35100000,934,YouTube +70,VEGETTA777,33400000,7128,YouTube +71,YouTube,33300000,538,YouTube +72,Markiplier,33300000,5198,YouTube +73,ABP NEWS,33200000,224084,YouTube +74,Mikecrack,33200000,1725,YouTube +75,Total Gaming,33200000,1892,YouTube +76,Maria Clara & JP,33100000,626,YouTube +77,Ryan's World,32900000,2197,YouTube +78,SSSniperWolf,32400000,3094,YouTube +79,KHANDESHI MOVIES,3.20E+07,190,YouTube +80,IndiaTV,31900000,237651,YouTube +81,La Granja de Zenón,31500000,557,YouTube +82,GENIAL,31400000,5446,YouTube +83,Selena Gomez,30900000,182,YouTube +84,Luis Fonsi,30900000,121,YouTube +85,Galinha Pintadinha,30800000,62,YouTube +86,Mr Bean,30700000,2657,YouTube +87,CVS 3D Rhymes & Kids Songs,30500000,338,YouTube +88,The Tonight Show Starring Jimmy Fallon,29900000,7890,YouTube +89,Dream,29900000,110,YouTube +90,rezendeevil,29600000,11568,YouTube +91,Spinnin' Records,29600000,10822,YouTube +92,Shawn Mendes,29500000,132,YouTube +93,BabyBus - Kids Songs and Cartoons,29200000,1821,YouTube +94,AuronPlay,29200000,404,YouTube +95,The Weeknd,29100000,123,YouTube +96,Jingle Toons,28600000,228,YouTube +97,Ultra Music,28600000,4664,YouTube +98,jacksepticeye,28600000,4988,YouTube +99,ashish chanchlani vines,28600000,147,YouTube +100,BillionSurpriseToys - English Kids Songs & Cartoon,28500000,511,YouTube +1,Ninja ,18296006,NA,Twitch  +2,auronplay ,13377575,NA,Twitch  +3,Rubius ,12524137,NA,Twitch  +4,Tfue ,11145556,NA,Twitch  +5,shroud ,10244388,NA,Twitch  +6,TheGrefg ,9638800,NA,Twitch  +7,pokimane ,8500996,NA,Twitch  +8,tommyinnit ,7255104,NA,Twitch  +9,TimTheTatman,6994697,NA,Twitch  +10,NICKMERCS ,6540633,NA,Twitch  +11,Dream,6047516,NA,Twitch  +12,AdinRoss ,5873745,NA,Twitch  +13,alanzoka ,5843207,NA,Twitch  +14,ESL_CSGO ,5526988,NA,Twitch  +15,Mongraal ,5239020,NA,Twitch  +16,Bugha ,5084551,NA,Twitch  +17,loltyler1 ,5033525,NA,Twitch  +18,Tubbo ,4917815,NA,Twitch  +19,GeorgeNotFound ,4829346,NA,Twitch  +20,ElSpreen ,4683364,NA,Twitch  +21,WilburSoot ,4573443,NA,Twitch  +22,Fresh,4476022,NA,Twitch  +23,RanbooLive ,4369464,NA,Twitch  +24,xQcOW ,4164752,NA,Twitch  +25,Philza ,4074041,NA,Twitch  +26,SLAKUN10 ,4037168,NA,Twitch  +27,Sykkuno,4033548,NA,Twitch  +28,Faker ,3849438,NA,Twitch  +29,Gotaga ,3670790,NA,Twitch  +30,Squeezie ,3614934,NA,Twitch  +31,Gaules ,3594823,NA,Twitch  +32,coscu ,3577250,NA,Twitch  +33,Clix ,3548355,NA,Twitch  +34,karljacobs ,3469785,NA,Twitch  +35,Elraenn ,3407910,NA,Twitch  +36,Asmongold ,3267875,NA,Twitch  +37,Amouranth ,3151328,NA,Twitch  +38,Alexby11 ,3146988,NA,Twitch  +39,ludwig,3136512,NA,Twitch  +40,buster ,3125548,NA,Twitch  +41,MissaSinfonia ,3116086,NA,Twitch  +42,QuackityHQ ,3089706,NA,Twitch  +43,Trymacs ,3069669,NA,Twitch  +44,IamCristinini ,3060175,NA,Twitch  +45,MontanaBlack88 ,3025471,NA,Twitch  +46,LIRIK ,2898083,NA,Twitch  +47,jacksepticeye ,2799824,NA,Twitch  +48,biyin_ ,2720743,NA,Twitch  +49,Nihachu ,2684804,NA,Twitch  +50,Staryuuki ,2660844,NA,Twitch  +51,lilypichu,2459116,NA,Twitch  +52,aXoZer ,2438304,NA,Twitch  +53,LITkillah ,2426822,NA,Twitch  +54,juansguarnizo ,2301844,NA,Twitch  +55,StableRonaldo_ ,2265402,NA,Twitch  +56,Twitch ,2262351,NA,Twitch  +57,Evelone192,2202177,NA,Twitch  +58,Reborn_Live ,2174515,NA,Twitch  +59,Perxitaa ,2170294,NA,Twitch  +60,Mizkif ,2081314,NA,Twitch  +61,pqueen ,2068579,NA,Twitch  +62,CaptainSparklez ,2040771,NA,Twitch  +63,Trainwreckstv ,2018898,NA,Twitch  +64,Yassuo ,1993853,NA,Twitch  +65,Locklear ,1862400,NA,Twitch  +66,DisguisedToast,1849885,NA,Twitch  +67,miniminter ,1778366,NA,Twitch  +68,PapoMC ,1775388,NA,Twitch  +69,wtcN ,1774208,NA,Twitch  +70,aroyitt ,1773486,NA,Twitch  +71,OverwatchLeague ,1767491,NA,Twitch  +72,Vicens ,1733508,NA,Twitch  +73,IzakOOO ,1721229,NA,Twitch  +74,Jahrein ,1674112,NA,Twitch  +75,DanTDM ,1666421,NA,Twitch  +76,NateHill ,1640757,NA,Twitch  +77,HasanAbi ,1630378,NA,Twitch  +78,Scarra ,1594992,NA,Twitch  +79,Gemita ,1578033,NA,Twitch  +80,CaptainPuffy ,1559591,NA,Twitch  +81,TheKAIRI78 ,1534189,NA,Twitch  +82,TSM_Bjergsen ,1509304,NA,Twitch  +83,Alinity ,1478896,NA,Twitch  +84,MarkiLokurasY ,1466343,NA,Twitch  +85,EmadGG ,1463690,NA,Twitch  +86,Domingo ,1453278,NA,Twitch  +87,FolagorLives ,1450178,NA,Twitch  +88,forsen ,1414311,NA,Twitch  +89,Mayichi ,1411861,NA,Twitch  +90,MrKeroro10 ,1359760,NA,Twitch  +91,Greekgodx ,1358155,NA,Twitch  +92,JaggerPrincesa ,1346284,NA,Twitch  +93,Pewdiepie ,1345762,NA,Twitch  +94,Corpse_Husband,1334278,NA,Twitch  +95,VEGETTA777 ,1323398,NA,Twitch  +96,landonorris ,1303704,NA,Twitch  +97,Zerkaa ,1303225,NA,Twitch  +98,ironmouse ,1294829,NA,Twitch  +99,bratishkinoff ,1289722,NA,Twitch  +100,itsHafu ,1279972,NA,Twitch  +1,charli d’amelio ,141200000,2211,TikTok +2,Khabane lame ,139700000,1055,TikTok +3,Bella Poarch ,89900000,470,TikTok +4,Addison Rae ,87700000,1683,TikTok +5,Will Smith ,72200000,136,TikTok +6,Zach King ,68600000,336,TikTok +7,Kimberly Loaiza ,63400000,1923,TikTok +8,TikTok ,62700000,342,TikTok +9,cznburak ,58800000,1870,TikTok +10,dixie ,57400000,472,TikTok +11,Spencer X ,5.50E+07,1302,TikTok +12,Dominik ,53500000,1333,TikTok +13,The Rock ,52800000,77,TikTok +14,Jason Derulo ,52400000,776,TikTok +15,Michael Le ,51400000,1270,TikTok +16,BTS ,50400000,54,TikTok +17,YZ ,46600000,1325,TikTok +18,Riyaz ,44900000,2055,TikTok +19, WonJeong ,44200000,1165,TikTok +20,Kris HC ,44100000,1329,TikTok +21,Brent Rivera ,43500000,1110,TikTok +22,Junya/ ,42500000,3180,TikTok +23,JoJo Siwa ,41600000,1618,TikTok +24,avani ,41300000,5936,TikTok +25, ,41200000,1214,TikTok +26,Joe ,4.10E+07,1919,TikTok +27,Selena Gomez ,4.10E+07,129,TikTok +28,ROD ,40700000,2352,TikTok +29,Carlos Feria ,3.90E+07,4046,TikTok +30,ondy mikula ,38800000,13200,TikTok +31,MrBeast ,3.70E+07,213,TikTok +32,nokhina Liza ,36200000,1664,TikTok +33,James Charles ,36200000,364,TikTok +34,BabyAriel ,35700000,2436,TikTok +35,Karol G ,3.50E+07,51,TikTok +36,tuzelity ,34400000,1805,TikTok +37,noah beck ,33400000,2260,TikTok +38,wigofellas,33100000,1497,TikTok +39,Mia K. ,32900000,489,TikTok +40,Gordon Ramsay ,32400000,283,TikTok +41,kyle thomas  ,32200000,9213,TikTok +42,Huddy ,32200000,3975,TikTok +43,Virginia ,31900000,970,TikTok +44,BRIANDA  ,31300000,3140,TikTok +45,Stokes Twins ,31200000,593,TikTok +46,Q Park ,31200000,296,TikTok +47,Benji Krol ,30900000,2372,TikTok +48,Kika Kim ,30600000,1057,TikTok +49,Liza Koshy ,29700000,186,TikTok +50,D A R I A NR O J A S ,29500000,512,TikTok +51,blackpinkofficial ,29400000,102,TikTok +52,Kira Kosarin ,29200000,1181,TikTok +53,Savannah LaBrant ,29200000,1909,TikTok +54,Kevin Hart ,29100000,72,TikTok +55,Topper Guild ,28800000,1728,TikTok +56,Arishfa Khan ,28700000,2016,TikTok +57,Kody Antle ,28600000,232,TikTok +58,Fernanda,28400000,3560,TikTok +59,JD Pantoja ,28300000,712,TikTok +60,flighthouse ,28300000,4606,TikTok +61,Ignacia Antonia ,28100000,5859,TikTok +62,lil nas x ,28100000,771,TikTok +63,Nisha Guragain ,28100000,1803,TikTok +64,Tirullipa ,28100000,2324,TikTok +65,Naim Darrechi ,2.80E+07,2979,TikTok +66,Camilo ,27800000,365,TikTok +67,ThatLittlePuff ,27700000,613,TikTok +68,arianagrande ,27300000,51,TikTok +69,psg ,27300000,648,TikTok +70,KEEMOKAZI ,27300000,1629,TikTok +71,Lele Pons ,27200000,374,TikTok +72,KingBach ,26600000,616,TikTok +73,Oneya D’Amelio ,26400000,528,TikTok +74,JeanCarlo Leon ,26300000,1607,TikTok +75,Daniel LaBelle ,26100000,290,TikTok +76,DAVID DOBRIK ,2.60E+07,594,TikTok +77,Kunno ,25900000,7466,TikTok +78,Era Ays ,25900000,4233,TikTok +79,LARRAY ,25700000,735,TikTok +80,Josh Richards ,25600000,2177,TikTok +81,ROSÉ ,25600000,50,TikTok +82,Celina Myers ,25500000,1399,TikTok +83,YOLO HOUSE ,25500000,2433,TikTok +84,adrilatinatv ,2.50E+07,2776,TikTok +85,Larissa Manoela ,2.50E+07,718,TikTok +86,TikTok_India ,24900000,184,TikTok +87,Doja Cat ,24800000,123,TikTok +88,Dina ,24700000,406,TikTok +89,Justin Bieber ,24700000,58,TikTok +90,DonaldDucc  ,24600000,2062,TikTok +91,SwagBoyQ on IG ,24500000,1379,TikTok +92,Sameeksha ,24400000,3318,TikTok +93,karolsevillaofc ,24400000,342,TikTok +94,Malu Trevejo ,24300000,2795,TikTok +95,ESPN ,2.40E+07,6492,TikTok +96,JAY CROES ,2.40E+07,2861,TikTok +97,Christoph ,23700000,2202,TikTok +98,Jacob Sartorius ,23700000,1942,TikTok +99,lizzo ,23500000,1270,TikTok +100,julia menu garcia ,23400000,4276,TikTok diff --git a/fluent-interface/README.md b/fluent-interface/README.md index 8b2a0442061e..a4bdef05b4b5 100644 --- a/fluent-interface/README.md +++ b/fluent-interface/README.md @@ -170,7 +170,6 @@ Use the Fluent Interface Pattern in Java when * [Google Guava FluentIterable](https://github.com/google/guava/wiki/FunctionalExplained) * [JOOQ](http://www.jooq.org/doc/3.0/manual/getting-started/use-cases/jooq-as-a-standalone-sql-builder/) * [Mockito](http://mockito.org/) -* [Java Hamcrest](http://code.google.com/p/hamcrest/wiki/Tutorial) * Builders in libraries like Apache Camel for integration workflows. ## Benefits and Trade-offs of Fluent Interface Pattern diff --git a/health-check/src/test/java/HealthEndpointIntegrationTest.java b/health-check/src/test/java/HealthEndpointIntegrationTest.java index da8dfaeca48b..7a2130f888ea 100644 --- a/health-check/src/test/java/HealthEndpointIntegrationTest.java +++ b/health-check/src/test/java/HealthEndpointIntegrationTest.java @@ -23,7 +23,6 @@ * THE SOFTWARE. */ import static io.restassured.RestAssured.given; -import static org.hamcrest.Matchers.equalTo; import com.iluwatar.health.check.App; import io.restassured.builder.RequestSpecBuilder; @@ -31,6 +30,9 @@ import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; import lombok.extern.slf4j.Slf4j; + +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -95,7 +97,8 @@ void healthEndpointReturnsUpStatus() { LOGGER.error("Health endpoint status: " + response.getStatusCode()); } - response.then().assertThat().statusCode(HttpStatus.OK.value()).body("status", equalTo("UP")); + response.then().assertThat().statusCode(HttpStatus.OK.value()); + assertTrue("UP".equals(response.path("status"))); } /** @@ -130,13 +133,14 @@ void healthEndpointReturnsCompleteDetails() { response .then() .assertThat() - .statusCode(HttpStatus.OK.value()) // Check that the status is UP - .body("status", equalTo("UP")) // Verify the status body is UP - .body("components.cpu.status", equalTo("UP")) // Check CPU status - .body("components.db.status", equalTo("UP")) // Check DB status - .body("components.diskSpace.status", equalTo("UP")) // Check disk space status - .body("components.ping.status", equalTo("UP")) // Check ping status - .body("components.custom.status", equalTo("UP")); // Check custom component status + .statusCode(HttpStatus.OK.value()); // Check that the status is UP + + assertTrue("UP".equals(response.path("status"))); // Verify the status body is UP + assertTrue("UP".equals(response.path("components.cpu.status"))); // Check CPU status + assertTrue("UP".equals(response.path("components.db.status"))); // Check DB status + assertTrue("UP".equals(response.path("components.diskSpace.status"))); // Check disk space status + assertTrue("UP".equals(response.path("components.ping.status"))); // Check ping status + assertTrue("UP".equals(response.path("components.custom.status"))); // Check custom component status // Check for "DOWN" status and high CPU load if ("DOWN".equals(response.path("status"))) { @@ -177,7 +181,8 @@ void livenessEndpointShouldReturnUpStatus() { } // If status is 200, proceed with additional checks - response.then().assertThat().statusCode(HttpStatus.OK.value()).body("status", equalTo("UP")); + response.then().assertThat().statusCode(HttpStatus.OK.value()); + assertTrue("UP".equals(response.path("status"))); // Check for "DOWN" status and high CPU load if ("DOWN".equals(response.path("status"))) { @@ -221,9 +226,9 @@ void customHealthIndicatorShouldReturnUpStatusAndDetails() { response .then() .assertThat() - .statusCode(HttpStatus.OK.value()) // Check that the status is UP - .body("components.custom.status", equalTo("UP")) // Verify the custom component status - .body("components.custom.details.database", equalTo("reachable")); // Verify custom details + .statusCode(HttpStatus.OK.value()); // Check that the status is UP + assertTrue("UP".equals(response.path("components.custom.status"))); // Verify the custom component status + assertTrue("reachable".equals(response.path("components.custom.details.database"))); // Verify custom details // Check for "DOWN" status and high CPU load if ("DOWN".equals(response.path("status"))) { diff --git a/marker-interface/pom.xml b/marker-interface/pom.xml index 43ee4bf78fd7..803441cf62c7 100644 --- a/marker-interface/pom.xml +++ b/marker-interface/pom.xml @@ -39,11 +39,6 @@ junit-jupiter-engine test - - org.hamcrest - hamcrest-core - test - diff --git a/marker-interface/src/test/java/GuardTest.java b/marker-interface/src/test/java/GuardTest.java index 9470689bc1ee..c5220d909572 100644 --- a/marker-interface/src/test/java/GuardTest.java +++ b/marker-interface/src/test/java/GuardTest.java @@ -22,8 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -35,6 +34,6 @@ class GuardTest { @Test void testGuard() { var guard = new Guard(); - assertThat(guard, instanceOf(Permission.class)); + assertTrue(guard instanceof Permission); } } \ No newline at end of file diff --git a/marker-interface/src/test/java/ThiefTest.java b/marker-interface/src/test/java/ThiefTest.java index 91f31293007f..41b5b4bb52bf 100644 --- a/marker-interface/src/test/java/ThiefTest.java +++ b/marker-interface/src/test/java/ThiefTest.java @@ -22,9 +22,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.MatcherAssert.assertThat; + +import static org.junit.jupiter.api.Assertions.assertFalse; import org.junit.jupiter.api.Test; @@ -35,6 +34,6 @@ class ThiefTest { @Test void testThief() { var thief = new Thief(); - assertThat(thief, not(instanceOf(Permission.class))); + assertFalse(thief instanceof Permission); } } \ No newline at end of file diff --git a/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/AppTest.java b/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/AppTest.java index e161b2edc30d..b72f5bffaac5 100644 --- a/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/AppTest.java +++ b/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/AppTest.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.idempotentconsumer; import org.junit.jupiter.api.Test; diff --git a/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/RequestStateMachineTests.java b/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/RequestStateMachineTests.java index af779648c8a3..083cff7ad05e 100644 --- a/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/RequestStateMachineTests.java +++ b/microservices-idempotent-consumer/src/test/java/com/iluwatar/idempotentconsumer/RequestStateMachineTests.java @@ -1,3 +1,27 @@ +/* + * This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt). + * + * The MIT License + * Copyright © 2014-2022 Ilkka Seppälä + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ package com.iluwatar.idempotentconsumer; import org.junit.jupiter.api.BeforeEach; diff --git a/retry/pom.xml b/retry/pom.xml index 331feb316b2e..fd35d9bafe44 100644 --- a/retry/pom.xml +++ b/retry/pom.xml @@ -40,11 +40,6 @@ junit-jupiter-engine test - - org.hamcrest - hamcrest-core - test - diff --git a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java index 3abd4f4e306a..9f6b635e4906 100644 --- a/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java +++ b/retry/src/test/java/com/iluwatar/retry/FindCustomerTest.java @@ -24,9 +24,8 @@ */ package com.iluwatar.retry; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; @@ -40,7 +39,7 @@ class FindCustomerTest { */ @Test void noExceptions() throws Exception { - assertThat(new FindCustomer("123").perform(), is("123")); + assertEquals(new FindCustomer("123").perform(), "123", "perform() output is not 123"); } /** @@ -75,6 +74,6 @@ void resultAfterExceptions() throws Exception { //ignore } - assertThat(op.perform(), is("123")); + assertEquals(op.perform(), "123", "op.perform() output is not 123"); } } diff --git a/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java b/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java index 085a1bd447e1..74d092411971 100644 --- a/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java +++ b/retry/src/test/java/com/iluwatar/retry/RetryExponentialBackoffTest.java @@ -24,9 +24,8 @@ */ package com.iluwatar.retry; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -54,7 +53,7 @@ void errors() { //ignore } - assertThat(retry.errors(), hasItem(e)); + assertTrue(retry.errors().contains(e)); } /** @@ -77,7 +76,7 @@ void attempts() { //ignore } - assertThat(retry.attempts(), is(1)); + assertEquals(retry.attempts(), 1, "Retry attempts do not equal 1"); } /** @@ -101,6 +100,6 @@ void ignore() { //ignore } - assertThat(retry.attempts(), is(2)); + assertEquals(retry.attempts(), 2, "Retry attempts do not equal 2"); } } diff --git a/retry/src/test/java/com/iluwatar/retry/RetryTest.java b/retry/src/test/java/com/iluwatar/retry/RetryTest.java index b400ef5e04c2..cf61ef435008 100644 --- a/retry/src/test/java/com/iluwatar/retry/RetryTest.java +++ b/retry/src/test/java/com/iluwatar/retry/RetryTest.java @@ -24,9 +24,8 @@ */ package com.iluwatar.retry; -import static org.hamcrest.CoreMatchers.hasItem; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -55,7 +54,7 @@ void errors() { //ignore } - assertThat(retry.errors(), hasItem(e)); + assertTrue(retry.errors().contains(e)); } /** @@ -78,7 +77,7 @@ void attempts() { //ignore } - assertThat(retry.attempts(), is(1)); + assertEquals(retry.attempts(), 1, "Retry attempts do not equal 1"); } /** @@ -102,7 +101,7 @@ void ignore() { //ignore } - assertThat(retry.attempts(), is(2)); + assertEquals(retry.attempts(), 2, "Retry attempts do not equal 2"); } } \ No newline at end of file diff --git a/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/RealVideoObjectTest.java b/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/RealVideoObjectTest.java index 90f20355677b..5ebec8def9d9 100644 --- a/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/RealVideoObjectTest.java +++ b/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/RealVideoObjectTest.java @@ -23,8 +23,7 @@ * THE SOFTWARE. */ package com.iluwatar.virtual.proxy; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.instanceOf; +import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import org.junit.jupiter.api.Test; @@ -37,7 +36,7 @@ class RealVideoObjectTest { @Test void testVideoObject() { var videoObject = new RealVideoObject(); - assertThat(videoObject, instanceOf(ExpensiveObject.class)); + assertTrue(videoObject instanceof ExpensiveObject); } @Test diff --git a/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/VideoObjectProxyTest.java b/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/VideoObjectProxyTest.java index 2ede2c8a412c..5daf56a1ae8b 100644 --- a/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/VideoObjectProxyTest.java +++ b/virtual-proxy/src/test/java/com/iluwatar/virtual/proxy/VideoObjectProxyTest.java @@ -25,10 +25,7 @@ package com.iluwatar.virtual.proxy; -import static org.hamcrest.core.IsInstanceOf.instanceOf; import static org.junit.jupiter.api.Assertions.*; - -import org.hamcrest.MatcherAssert; import org.junit.jupiter.api.Test; /** @@ -37,7 +34,7 @@ public class VideoObjectProxyTest { @Test void shouldBeInstanceOfExpensiveObject() { - MatcherAssert.assertThat(new VideoObjectProxy(), instanceOf(ExpensiveObject.class)); + assertTrue(new VideoObjectProxy() instanceof ExpensiveObject); } @Test