@Test public void testGetCommandHistory_pagination() { Manager manager = Mockito.mock( Manager.class ); ICommandsMngr commandsMngr = Mockito.mock( ICommandsMngr.class ); Mockito.when( manager.commandsMngr()).thenReturn( commandsMngr ); this.resource = new HistoryResource( manager ); List<CommandHistoryItem> items = this.resource.getCommandHistory( 10, null, 10, "start", null ); Assert.assertEquals( 0, items.size()); Mockito.verify( commandsMngr ).getHistory( 90, 10, "start", null, null ); Mockito.reset( commandsMngr ); items = this.resource.getCommandHistory( -2, null, 10, null, "asc" ); Assert.assertEquals( 0, items.size()); Mockito.verify( commandsMngr ).getHistory( 0, 10, null, "asc", null ); Mockito.reset( commandsMngr ); items = this.resource.getCommandHistory( 1, null, 10, null, "asc" ); Assert.assertEquals( 0, items.size()); Mockito.verify( commandsMngr ).getHistory( 0, 10, null, "asc", null ); Mockito.reset( commandsMngr ); items = this.resource.getCommandHistory( 2, "app", 10, null, "asc" ); Assert.assertEquals( 0, items.size()); Mockito.verify( commandsMngr ).getHistory( 10, 10, null, "asc", "app" ); }
@Override public List<CommandHistoryItem> getCommandHistory( int pageNumber, String applicationName, int itemsPerPage, String sortingCriteria, String sortingOrder ) { if( pageNumber < 1 ) pageNumber = 1; this.logger.fine( "Request: get the history of commands execution (page = " + pageNumber + ")." ); return this.manager.commandsMngr().getHistory( (pageNumber -1) * itemsPerPage, itemsPerPage, sortingCriteria, sortingOrder, applicationName ); }
HistoryResource implements IHistoryResource { @Override public List<CommandHistoryItem> getCommandHistory( int pageNumber, String applicationName, int itemsPerPage, String sortingCriteria, String sortingOrder ) { if( pageNumber < 1 ) pageNumber = 1; this.logger.fine( "Request: get the history of commands execution (page = " + pageNumber + ")." ); return this.manager.commandsMngr().getHistory( (pageNumber -1) * itemsPerPage, itemsPerPage, sortingCriteria, sortingOrder, applicationName ); } }
HistoryResource implements IHistoryResource { @Override public List<CommandHistoryItem> getCommandHistory( int pageNumber, String applicationName, int itemsPerPage, String sortingCriteria, String sortingOrder ) { if( pageNumber < 1 ) pageNumber = 1; this.logger.fine( "Request: get the history of commands execution (page = " + pageNumber + ")." ); return this.manager.commandsMngr().getHistory( (pageNumber -1) * itemsPerPage, itemsPerPage, sortingCriteria, sortingOrder, applicationName ); } HistoryResource( Manager manager ); }
HistoryResource implements IHistoryResource { @Override public List<CommandHistoryItem> getCommandHistory( int pageNumber, String applicationName, int itemsPerPage, String sortingCriteria, String sortingOrder ) { if( pageNumber < 1 ) pageNumber = 1; this.logger.fine( "Request: get the history of commands execution (page = " + pageNumber + ")." ); return this.manager.commandsMngr().getHistory( (pageNumber -1) * itemsPerPage, itemsPerPage, sortingCriteria, sortingOrder, applicationName ); } HistoryResource( Manager manager ); @Override Response getCommandHistoryNumberOfPages( String applicationName, int itemsPerPage ); @Override List<CommandHistoryItem> getCommandHistory(
			int pageNumber,
			String applicationName,
			int itemsPerPage,
			String sortingCriteria,
			String sortingOrder ); }
HistoryResource implements IHistoryResource { @Override public List<CommandHistoryItem> getCommandHistory( int pageNumber, String applicationName, int itemsPerPage, String sortingCriteria, String sortingOrder ) { if( pageNumber < 1 ) pageNumber = 1; this.logger.fine( "Request: get the history of commands execution (page = " + pageNumber + ")." ); return this.manager.commandsMngr().getHistory( (pageNumber -1) * itemsPerPage, itemsPerPage, sortingCriteria, sortingOrder, applicationName ); } HistoryResource( Manager manager ); @Override Response getCommandHistoryNumberOfPages( String applicationName, int itemsPerPage ); @Override List<CommandHistoryItem> getCommandHistory(
			int pageNumber,
			String applicationName,
			int itemsPerPage,
			String sortingCriteria,
			String sortingOrder );  }