package com.wheany;

import com.wheany.generated.rss.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.IOException;
import java.net.MalformedURLException;

@SpringBootApplication
public class RSSifier {

    public static final String DOWNLOAD_TEST_URL = "https://wheany.com/test/";

    public static void main(String[] args) {
        JAXBContext jaxbContext;
        Unmarshaller jaxbUnmarshaller;
        Rss rss;
        try {
            jaxbContext = JAXBContext.newInstance(Rss.class);
            jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            rss = (Rss) jaxbUnmarshaller.unmarshal(RSSifier.class.getResourceAsStream("/Liftoff News.xml"));
        } catch (JAXBException e) {
            e.printStackTrace();
            rss = new Rss();
        }

        rss.getChannel().getItemOrTitleOrLinkOrDescriptionOrLanguageOrCopyrightOrManagingEditorOrWebMasterOrPubDateOrLastBuildDateOrCategoryOrGeneratorOrDocsOrCloudOrTtlOrImageOrTextInputOrSkipHoursOrSkipDays()
                .stream()
                .filter(channelItem -> channelItem instanceof Item)
                .forEach(channelItem -> {
                    Item item = (Item) channelItem;
                    for (Object titleOrDescription : item.getTitleOrDescription()) {
                        if (titleOrDescription instanceof Title) {
                            System.out.println("Title:" + ((Title) titleOrDescription).getvalue());
                        }
                        if (titleOrDescription instanceof Description) {
                            System.out.println("Description:" + ((Description) titleOrDescription).getvalue());
                        }
                    }

                    for (Object subItem : item.getAuthorOrCategoryOrCommentsOrEnclosureOrGuidOrPubDateOrSource()) {
                        if (subItem instanceof Guid) {
                            System.out.println("Guid:" + ((Guid) subItem).getvalue());
                        }
                        if (subItem instanceof Author) {
                            System.out.println("Author:" + ((Author) subItem).getvalue());
                        }
                    }
                    if (item.getLink() != null) {
                        System.out.println("Link:" + item.getLink().getvalue());
                    }
                });
        try {
            Downloader downloader = new Downloader(DOWNLOAD_TEST_URL);

            Document document = Jsoup.parse(downloader.download().toFile(), null, DOWNLOAD_TEST_URL);

            Elements elements = document.select("a[href]");

            elements.stream().forEach(element -> System.out.println("Element:" + element.outerHtml()));

        } catch (MalformedURLException e) {
            System.err.println("Malformed URL");
            e.printStackTrace();
        } catch (IOException e) {
            System.err.println("IO exception");
            e.printStackTrace();
        }
        SpringApplication.run(RSSifier.class, args);
    }
}

@@ -614,2626 +614,8 @@
 ) %7B%0A
-        JAXBContext jaxbContext;%0A        Unmarshaller jaxbUnmarshaller;%0A        Rss rss;%0A        try %7B%0A            jaxbContext = JAXBContext.newInstance(Rss.class);%0A            jaxbUnmarshaller = jaxbContext.createUnmarshaller();%0A            rss = (Rss) jaxbUnmarshaller.unmarshal(RSSifier.class.getResourceAsStream(%22/Liftoff News.xml%22));%0A        %7D catch (JAXBException e) %7B%0A            e.printStackTrace();%0A            rss = new Rss();%0A        %7D%0A%0A        rss.getChannel().getItemOrTitleOrLinkOrDescriptionOrLanguageOrCopyrightOrManagingEditorOrWebMasterOrPubDateOrLastBuildDateOrCategoryOrGeneratorOrDocsOrCloudOrTtlOrImageOrTextInputOrSkipHoursOrSkipDays()%0A                .stream()%0A                .filter(channelItem -%3E channelItem instanceof Item)%0A                .forEach(channelItem -%3E %7B%0A                    Item item = (Item) channelItem;%0A                    for (Object titleOrDescription : item.getTitleOrDescription()) %7B%0A                        if (titleOrDescription instanceof Title) %7B%0A                            System.out.println(%22Title:%22 + ((Title) titleOrDescription).getvalue());%0A                        %7D%0A                        if (titleOrDescription instanceof Description) %7B%0A                            System.out.println(%22Description:%22 + ((Description) titleOrDescription).getvalue());%0A                        %7D%0A                    %7D%0A%0A                    for (Object subItem : item.getAuthorOrCategoryOrCommentsOrEnclosureOrGuidOrPubDateOrSource()) %7B%0A                        if (subItem instanceof Guid) %7B%0A                            System.out.println(%22Guid:%22 + ((Guid) subItem).getvalue());%0A                        %7D%0A                        if (subItem instanceof Author) %7B%0A                            System.out.println(%22Author:%22 + ((Author) subItem).getvalue());%0A                        %7D%0A                    %7D%0A                    if (item.getLink() != null) %7B%0A                        System.out.println(%22Link:%22 + item.getLink().getvalue());%0A                    %7D%0A                %7D);%0A        try %7B%0A            Downloader downloader = new Downloader(DOWNLOAD_TEST_URL);%0A%0A            Document document = Jsoup.parse(downloader.download().toFile(), null, DOWNLOAD_TEST_URL);%0A%0A            Elements elements = document.select(%22a%5Bhref%5D%22);%0A%0A            elements.stream().forEach(element -%3E System.out.println(%22Element:%22 + element.outerHtml()));%0A%0A        %7D catch (MalformedURLException e) %7B%0A            System.err.println(%22Malformed URL%22);%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            System.err.println(%22IO exception%22);%0A            e.printStackTrace();%0A        %7D%0A
     

Remove test code from main