@Test public void testGeneration() throws Exception { Xml xml = testee.getAndStoreResultToDatabase(URI.create("http: NewznabXmlRoot root = (NewznabXmlRoot) xml; System.out.println(root); }
protected Xml getAndStoreResultToDatabase(URI uri, IndexerApiAccessType apiAccessType) throws IndexerAccessException { NewznabXmlRoot rssRoot = new NewznabXmlRoot(); if (uri.toString().contains("oneduplicate")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(1); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); } else if (uri.toString().contains("duplicatesandtitlegroups")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100")); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot3 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot3.getRssChannel().getItems().get(0).getEnclosure().setLength(200000L); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000")); rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0)); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("anotherresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot2 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().add(rssRoot2.getRssChannel().getItems().get(0)); rssRoot.getRssChannel().getNewznabResponse().setTotal(3); } else if (uri.toString().contains("duplicates")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(10).titleBase("duplicates").titleWords(Collections.emptyList()).total(10).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(10); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { rssItem.getEnclosure().setLength(100000L); rssItem.getNewznabAttributes().clear(); rssItem.setPubDate(Instant.now()); rssItem.setDescription("Indexer: " + getName() + ", title:" + rssItem.getTitle()); } } else if (uri.toString().contains("tworesults")) { rssRoot = NewznabMockBuilder.generateResponse(0, 2, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(2); } else { rssRoot = NewznabMockBuilder.generateResponse(0, 100, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(100); } if (uri.toString().contains("punkte")) { rssRoot.getRssChannel().getItems().get(0).setTitle("a a"); rssRoot.getRssChannel().getItems().get(1).setTitle("ab"); rssRoot.getRssChannel().getItems().get(2).setTitle("a.c"); } return rssRoot; }
DevIndexer extends Newznab { protected Xml getAndStoreResultToDatabase(URI uri, IndexerApiAccessType apiAccessType) throws IndexerAccessException { NewznabXmlRoot rssRoot = new NewznabXmlRoot(); if (uri.toString().contains("oneduplicate")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(1); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); } else if (uri.toString().contains("duplicatesandtitlegroups")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100")); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot3 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot3.getRssChannel().getItems().get(0).getEnclosure().setLength(200000L); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000")); rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0)); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("anotherresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot2 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().add(rssRoot2.getRssChannel().getItems().get(0)); rssRoot.getRssChannel().getNewznabResponse().setTotal(3); } else if (uri.toString().contains("duplicates")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(10).titleBase("duplicates").titleWords(Collections.emptyList()).total(10).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(10); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { rssItem.getEnclosure().setLength(100000L); rssItem.getNewznabAttributes().clear(); rssItem.setPubDate(Instant.now()); rssItem.setDescription("Indexer: " + getName() + ", title:" + rssItem.getTitle()); } } else if (uri.toString().contains("tworesults")) { rssRoot = NewznabMockBuilder.generateResponse(0, 2, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(2); } else { rssRoot = NewznabMockBuilder.generateResponse(0, 100, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(100); } if (uri.toString().contains("punkte")) { rssRoot.getRssChannel().getItems().get(0).setTitle("a a"); rssRoot.getRssChannel().getItems().get(1).setTitle("ab"); rssRoot.getRssChannel().getItems().get(2).setTitle("a.c"); } return rssRoot; } }
DevIndexer extends Newznab { protected Xml getAndStoreResultToDatabase(URI uri, IndexerApiAccessType apiAccessType) throws IndexerAccessException { NewznabXmlRoot rssRoot = new NewznabXmlRoot(); if (uri.toString().contains("oneduplicate")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(1); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); } else if (uri.toString().contains("duplicatesandtitlegroups")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100")); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot3 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot3.getRssChannel().getItems().get(0).getEnclosure().setLength(200000L); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000")); rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0)); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("anotherresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot2 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().add(rssRoot2.getRssChannel().getItems().get(0)); rssRoot.getRssChannel().getNewznabResponse().setTotal(3); } else if (uri.toString().contains("duplicates")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(10).titleBase("duplicates").titleWords(Collections.emptyList()).total(10).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(10); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { rssItem.getEnclosure().setLength(100000L); rssItem.getNewznabAttributes().clear(); rssItem.setPubDate(Instant.now()); rssItem.setDescription("Indexer: " + getName() + ", title:" + rssItem.getTitle()); } } else if (uri.toString().contains("tworesults")) { rssRoot = NewznabMockBuilder.generateResponse(0, 2, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(2); } else { rssRoot = NewznabMockBuilder.generateResponse(0, 100, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(100); } if (uri.toString().contains("punkte")) { rssRoot.getRssChannel().getItems().get(0).setTitle("a a"); rssRoot.getRssChannel().getItems().get(1).setTitle("ab"); rssRoot.getRssChannel().getItems().get(2).setTitle("a.c"); } return rssRoot; }  }
DevIndexer extends Newznab { protected Xml getAndStoreResultToDatabase(URI uri, IndexerApiAccessType apiAccessType) throws IndexerAccessException { NewznabXmlRoot rssRoot = new NewznabXmlRoot(); if (uri.toString().contains("oneduplicate")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(1); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); } else if (uri.toString().contains("duplicatesandtitlegroups")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100")); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot3 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot3.getRssChannel().getItems().get(0).getEnclosure().setLength(200000L); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000")); rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0)); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("anotherresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot2 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().add(rssRoot2.getRssChannel().getItems().get(0)); rssRoot.getRssChannel().getNewznabResponse().setTotal(3); } else if (uri.toString().contains("duplicates")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(10).titleBase("duplicates").titleWords(Collections.emptyList()).total(10).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(10); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { rssItem.getEnclosure().setLength(100000L); rssItem.getNewznabAttributes().clear(); rssItem.setPubDate(Instant.now()); rssItem.setDescription("Indexer: " + getName() + ", title:" + rssItem.getTitle()); } } else if (uri.toString().contains("tworesults")) { rssRoot = NewznabMockBuilder.generateResponse(0, 2, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(2); } else { rssRoot = NewznabMockBuilder.generateResponse(0, 100, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(100); } if (uri.toString().contains("punkte")) { rssRoot.getRssChannel().getItems().get(0).setTitle("a a"); rssRoot.getRssChannel().getItems().get(1).setTitle("ab"); rssRoot.getRssChannel().getItems().get(2).setTitle("a.c"); } return rssRoot; }   }
DevIndexer extends Newznab { protected Xml getAndStoreResultToDatabase(URI uri, IndexerApiAccessType apiAccessType) throws IndexerAccessException { NewznabXmlRoot rssRoot = new NewznabXmlRoot(); if (uri.toString().contains("oneduplicate")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(1); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); } else if (uri.toString().contains("duplicatesandtitlegroups")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().get(0).getEnclosure().setLength(100000L); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "100")); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("oneresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot3 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot3.getRssChannel().getItems().get(0).getEnclosure().setLength(200000L); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getTorznabAttributes().clear(); rssRoot3.getRssChannel().getItems().get(0).getNewznabAttributes().add(new NewznabAttribute("grabs", "2000")); rssRoot3.getRssChannel().getItems().get(0).setLink("anotherlink"); rssRoot.getRssChannel().getItems().add(rssRoot3.getRssChannel().getItems().get(0)); mockRequest = NewznabMockRequest.builder().numberOfResults(1).titleBase("anotherresult").titleWords(Collections.emptyList()).total(1).build(); NewznabXmlRoot rssRoot2 = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getItems().add(rssRoot2.getRssChannel().getItems().get(0)); rssRoot.getRssChannel().getNewznabResponse().setTotal(3); } else if (uri.toString().contains("duplicates")) { NewznabMockRequest mockRequest = NewznabMockRequest.builder().numberOfResults(10).titleBase("duplicates").titleWords(Collections.emptyList()).total(10).build(); rssRoot = NewznabMockBuilder.generateResponse(mockRequest); rssRoot.getRssChannel().getNewznabResponse().setTotal(10); for (NewznabXmlItem rssItem : rssRoot.getRssChannel().getItems()) { rssItem.getEnclosure().setLength(100000L); rssItem.getNewznabAttributes().clear(); rssItem.setPubDate(Instant.now()); rssItem.setDescription("Indexer: " + getName() + ", title:" + rssItem.getTitle()); } } else if (uri.toString().contains("tworesults")) { rssRoot = NewznabMockBuilder.generateResponse(0, 2, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(2); } else { rssRoot = NewznabMockBuilder.generateResponse(0, 100, "results", false, Collections.emptyList(), false, 0); rssRoot.getRssChannel().getNewznabResponse().setTotal(100); } if (uri.toString().contains("punkte")) { rssRoot.getRssChannel().getItems().get(0).setTitle("a a"); rssRoot.getRssChannel().getItems().get(1).setTitle("ab"); rssRoot.getRssChannel().getItems().get(2).setTitle("a.c"); } return rssRoot; }    }