@Test
public void testGetLatestAnalyticsTable()
{

    Date lastFullTableUpdate = new DateTime( 2019, 3, 1, 2, 0 ).toDate();
    Date lastLatestPartitionUpdate = new DateTime( 2019, 3, 1, 9, 0 ).toDate();
    Date startTime = new DateTime( 2019, 3, 1, 10, 0 ).toDate();
    AnalyticsTableUpdateParams params = AnalyticsTableUpdateParams.newBuilder()
        .withStartTime( startTime )
        .withLatestPartition()
        .build();
    List<Map<String, Object>> queryResp = Lists.newArrayList();
    queryResp.add( ImmutableMap.of( "dataelementid", 1 ) );
    when( systemSettingManager.getSystemSetting( SettingKey.LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE ) ).thenReturn( lastFullTableUpdate );
    when( systemSettingManager.getSystemSetting( SettingKey.LAST_SUCCESSFUL_LATEST_ANALYTICS_PARTITION_UPDATE ) ).thenReturn( lastLatestPartitionUpdate );
    when( jdbcTemplate.queryForList( Mockito.anyString() ) ).thenReturn( queryResp );
    List<AnalyticsTable> tables = subject.getAnalyticsTables( params );
    assertEquals( 1, tables.size() );
    AnalyticsTable table = tables.get( 0 );
    assertNotNull( table );
    assertNotNull( table.getTablePartitions() );
    assertEquals( 1, table.getTablePartitions().size() );
    AnalyticsTablePartition partition = table.getLatestPartition();
    assertNotNull( partition );
    assertTrue( partition.isLatestPartition() );
    assertEquals( lastFullTableUpdate, partition.getStartDate() );
    assertEquals( startTime, partition.getEndDate() );
}