/*
 * Copyright © 2018 Mercateo AG (http://www.mercateo.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.factcast.store.pgsql.internal.query;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.jdbc.core.JdbcTemplate;

@ExtendWith(MockitoExtension.class)
public class PgLatestSerialFetcherTest {
    @InjectMocks
    PgLatestSerialFetcher uut;

    @Mock
    JdbcTemplate jdbc;

    @Test
    public void testRetrieveLatestSerRetuns0WhenExceptionThrown() throws Exception {
        when(jdbc.queryForRowSet(anyString())).thenThrow(UnsupportedOperationException.class);
        assertEquals(0, uut.retrieveLatestSer());
    }

}

@@ -1066,16 +1066,74 @@
 emplate;
+%0Aimport org.springframework.jdbc.support.rowset.SqlRowSet;
 %0A%0A@Exten
@@ -1286,16 +1286,45 @@
  jdbc;%0A%0A
+    @Mock%0A    SqlRowSet rs;%0A%0A
     @Tes
@@ -1410,16 +1410,16 @@
 ption %7B%0A
-
         
@@ -1562,10 +1562,245 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void shouldReturn0IfNotFound() throws Exception %7B%0A        when(jdbc.queryForRowSet(anyString())).thenReturn(rs);%0A        when(rs.next()).thenReturn(false);%0A%0A        assertEquals(0, uut.retrieveLatestSer());%0A    %7D%0A%0A
 %7D%0A

improve coverage