test_class.declarator: downloaderService
test_class.modifier: private
test_class.original_string: private FileDownloaderService downloaderService;
test_class.type: FileDownloaderService
test_class.var_name: downloaderService
test_class.declarator: robotsRepository
test_class.modifier: private
test_class.original_string: private RobotsRepository robotsRepository;
test_class.type: RobotsRepository
test_class.var_name: robotsRepository
test_class.declarator: consumerService
test_class.modifier: private
test_class.original_string: private IncomingUrlService consumerService;
test_class.type: IncomingUrlService
test_class.var_name: consumerService
test_class.declarator: redisUrlRepository
test_class.modifier: private
test_class.original_string: private RedisUrlRepository redisUrlRepository;
test_class.type: RedisUrlRepository
test_class.var_name: redisUrlRepository
test_class.file: downloader/src/test/java/com/fooock/robotstxt/downloader/service/IncomingUrlServiceTest.java
test_class.identifier: IncomingUrlServiceTest
test_case.body: @Test
      public void testUrlExistsAndNeedsToBeUpdated() throws Exception {
          String url = "http://test.example.com/hello";
          Entry entry = createEntry(url, 2880); // two days
          when(robotsRepository.findByHost(anyString())).thenReturn(entry);
          when(redisUrlRepository.exists(anyString())).thenReturn(false);
  
          consumerService.receiveUrl(url);
  
          String baseHost = DomainUtils.base(new URI(url));
          String robotUrl = String.format("%s/robots.txt", baseHost);
          verify(downloaderService, times(1)).download(eq(baseHost), eq(robotUrl));
      }
test_case.class_method_signature: IncomingUrlServiceTest.testUrlExistsAndNeedsToBeUpdated()
test_case.full_signature: @Test public void testUrlExistsAndNeedsToBeUpdated()
test_case.identifier: testUrlExistsAndNeedsToBeUpdated
test_case.invocations: createEntry thenReturn when findByHost anyString thenReturn when exists anyString receiveUrl base format download verify times eq eq
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUrlExistsAndNeedsToBeUpdated()
focal_class.declarator: robotsRepository
focal_class.modifier: private final
focal_class.original_string: private final RobotsRepository robotsRepository;
focal_class.type: RobotsRepository
focal_class.var_name: robotsRepository
focal_class.declarator: downloaderService
focal_class.modifier: private final
focal_class.original_string: private final FileDownloaderService downloaderService;
focal_class.type: FileDownloaderService
focal_class.var_name: downloaderService
focal_class.declarator: redisUrlRepository
focal_class.modifier: private final
focal_class.original_string: private final RedisUrlRepository redisUrlRepository;
focal_class.type: RedisUrlRepository
focal_class.var_name: redisUrlRepository
focal_class.file: downloader/src/main/java/com/fooock/robotstxt/downloader/service/IncomingUrlService.java
focal_class.identifier: IncomingUrlService
focal_class.class_method_signature: IncomingUrlService.receiveUrl(String url)
focal_class.full_signature: public void receiveUrl(String url)
focal_class.identifier: receiveUrl
focal_class.modifiers: public
focal_class.parameters: (String url)
focal_class.return: void
focal_class.signature: void receiveUrl(String url)
focal_class.class_method_signature: IncomingUrlService.checkHost(String host)
focal_class.full_signature: private void checkHost(String host)
focal_class.identifier: checkHost
focal_class.modifiers: private
focal_class.parameters: (String host)
focal_class.return: void
focal_class.signature: void checkHost(String host)
focal_class.class_method_signature: IncomingUrlService.downloadRules(String host)
focal_class.full_signature: private void downloadRules(String host)
focal_class.identifier: downloadRules
focal_class.modifiers: private
focal_class.parameters: (String host)
focal_class.return: void
focal_class.signature: void downloadRules(String host)
focal_method.body: public void receiveUrl(String url) {
          // Check if url is a valid http or https resource
          if (!UrlUtils.isValid(url)) {
              log.error("Url {} is not valid", url);
              return;
          }
          log.info("Received url {}, prepared to fetch robots.txt file for it", url);
          try {
              // Extract base url to create robots.txt url
              URI uri = new URI(url);
              String baseHost = DomainUtils.base(uri);
  
              log.debug("Validated url to base host: {}", baseHost);
              checkHost(baseHost);
  
          } catch (URISyntaxException e) {
              log.error("Can't create URI using url {}", url, e);
          }
      }
focal_method.class_method_signature: IncomingUrlService.receiveUrl(String url)
focal_method.full_signature: public void receiveUrl(String url)
focal_method.identifier: receiveUrl
focal_method.invocations: isValid error info base debug checkHost error
focal_method.modifiers: public
focal_method.parameters: (String url)
focal_method.return: void
focal_method.signature: void receiveUrl(String url)