test_class.declarator: logger = LoggerFactory.getLogger(PaginationBuilderServiceTest.class)
test_class.modifier: private
test_class.original_string: private Logger logger = LoggerFactory.getLogger(PaginationBuilderServiceTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: paginationBuilderService
test_class.modifier: private
test_class.original_string: private PaginationBuilderService paginationBuilderService;
test_class.type: PaginationBuilderService
test_class.var_name: paginationBuilderService
test_class.file: eu.alert-project.iccs.stardom.core/eu.alert-project.iccs.stardom.ui/src/test/java/eu/alertproject/iccs/stardom/ui/utils/PaginationBuilderServiceTest.java
test_class.identifier: PaginationBuilderServiceTest
test_case.body: @Test
      public void testEnd(){
  
          Map<String,Object> stringObjectMap = paginationBuilderService.buildPages(13, 15, 6);
  
          Integer[] pages = (Integer[]) stringObjectMap.get("pages");
          Integer selected = (Integer) stringObjectMap.get("selected");
  
  
          Assert.assertEquals(13,selected, 0);
          Assert.assertEquals(13, pages.length);
  
          // 1,2,| 3,4,5,6,7,8,9,10,11,12,[13],14,15 |
          testPages(pages,
                  new Integer[]{
                        3,4,5,6,7,8,9,10,11,12,13,14,15
                  });
  
      }
test_case.class_method_signature: PaginationBuilderServiceTest.testEnd()
test_case.full_signature: @Test public void testEnd()
test_case.identifier: testEnd
test_case.invocations: buildPages get get assertEquals assertEquals testPages
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testEnd()
focal_class.declarator: logger = LoggerFactory.getLogger(PaginationBuilderService.class)
focal_class.modifier: private
focal_class.original_string: private Logger logger = LoggerFactory.getLogger(PaginationBuilderService.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: eu.alert-project.iccs.stardom.core/eu.alert-project.iccs.stardom.ui/src/main/java/eu/alertproject/iccs/stardom/ui/utils/PaginationBuilderService.java
focal_class.identifier: PaginationBuilderService
focal_class.class_method_signature: PaginationBuilderService.buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_class.full_signature: public Map<String, Object> buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_class.identifier: buildPages
focal_class.modifiers: public
focal_class.parameters: (
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_method.body: public Map<String, Object> buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      ){
  
  
          logger.trace("Map<String,Object> buildPages(selectedPage= {},totalPages={},depthSize={})",new Object[]{selectedPage,totalPages,depthSize});
          Map<String,Object> pagination = new HashMap<String, Object>();
  
  
          // depthSize*2 = Left an right number of pages
          // +1 The selected page
          //protect the return size
          int returnSize = Math.min(((depthSize*2)+1),totalPages);
  
          Integer[] pages = new Integer[returnSize];
  
          /*
            * If the selected page is less that the depthSize,
            * there is no need to scroll the bottom results
           */
          if(selectedPage <= depthSize+1){
              logger.trace("Map<String,Object> buildPages(pages) Keeping to left side no need to scroll ");
              //no need to scroll the results
              for(int i =1; i <= returnSize ; i++){
                  pages[i-1]=i;
              }
          }else if( selectedPage > totalPages - (depthSize*2)){
  
              logger.trace("Map<String,Object> buildPages(pages) Working from right <- left, not enough spaces on the right {}",returnSize);
  
              //from right to left
              for(int i =0 ; i < returnSize; i++){
                  pages[i] = (totalPages-returnSize+1)+i;
              }
  
  
          }else{
              //it is in the middle
              //get the previous four numbers and the next four numbers
  
              pages[depthSize]=selectedPage;
              for(int i=0; i< depthSize; i++){
  
                  pages[i]= selectedPage-(depthSize-i);
                  pages[depthSize+1+i] = selectedPage+1+i;
              }
  
  
  
          }
  
  
          pagination.put("first",1);
          pagination.put("pages",pages);
          pagination.put("last",totalPages);
          pagination.put("selected",selectedPage);
  
          return pagination;
      }
focal_method.class_method_signature: PaginationBuilderService.buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_method.full_signature: public Map<String, Object> buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_method.identifier: buildPages
focal_method.invocations: trace min trace trace put put put put
focal_method.modifiers: public
focal_method.parameters: (
              Integer selectedPage,
              int totalPages,
              int depthSize
      )
focal_method.return: Map<String, Object>
focal_method.signature: Map<String, Object> buildPages(
              Integer selectedPage,
              int totalPages,
              int depthSize
      )