Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • osdu/platform/system/indexer-service
  • schundu/indexer-service
2 results
Show changes
Commits on Source (5)
...@@ -32,6 +32,7 @@ import java.io.UnsupportedEncodingException; ...@@ -32,6 +32,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Objects;
/** /**
* Provides implementation of the client service that retrieves schemas from the Schema Service * Provides implementation of the client service that retrieves schemas from the Schema Service
...@@ -58,13 +59,9 @@ public class SchemaProviderImpl implements SchemaService { ...@@ -58,13 +59,9 @@ public class SchemaProviderImpl implements SchemaService {
@Override @Override
public String getSchema(String kind) throws URISyntaxException, UnsupportedEncodingException { public String getSchema(String kind) throws URISyntaxException, UnsupportedEncodingException {
String schemaFromStorageService = getFromStorageService(kind); String schemaServiceSchema = getFromSchemaService(kind);
if (schemaFromStorageService != null) { return Objects.nonNull(schemaServiceSchema) ? schemaServiceSchema : getFromStorageService(kind);
return schemaFromStorageService;
}
return getFromSchemaService(kind);
} }
protected String getFromSchemaService(String kind) throws UnsupportedEncodingException, URISyntaxException { protected String getFromSchemaService(String kind) throws UnsupportedEncodingException, URISyntaxException {
......
...@@ -136,7 +136,7 @@ public class SchemaProviderImplTest { ...@@ -136,7 +136,7 @@ public class SchemaProviderImplTest {
} }
@Test @Test
public void should_call_Storage_then_Schema() throws Exception { public void should_call_Schema_then_Storage() throws Exception {
String kind = "tenant:test:test:1.0.0"; String kind = "tenant:test:test:1.0.0";
SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class); SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class);
...@@ -148,20 +148,20 @@ public class SchemaProviderImplTest { ...@@ -148,20 +148,20 @@ public class SchemaProviderImplTest {
assertNull(recordSchemaResponse); assertNull(recordSchemaResponse);
inOrder.verify(schemaService).getSchema(any()); inOrder.verify(schemaService).getSchema(any());
inOrder.verify(schemaService).getFromStorageService(any());
inOrder.verify(schemaService).getFromSchemaService(any()); inOrder.verify(schemaService).getFromSchemaService(any());
inOrder.verify(schemaService).getFromStorageService(any());
verify(schemaService, times(1)).getFromStorageService(any()); verify(schemaService, times(1)).getFromStorageService(any());
verify(schemaService, times(1)).getFromSchemaService(any()); verify(schemaService, times(1)).getFromSchemaService(any());
} }
@Test @Test
public void should_call_only_Storage_if_it_returns_result() throws Exception { public void should_call_only_SchemaService_if_it_returns_result() throws Exception {
String kind = "tenant:test:test:1.0.0"; String kind = "tenant:test:test:1.0.0";
SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class); SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class);
when(schemaService.getSchema(any())).thenCallRealMethod(); when(schemaService.getSchema(any())).thenCallRealMethod();
String someSchema = "some schema"; String someSchema = "some schema";
when(schemaService.getFromStorageService(any())).thenReturn(someSchema); when(schemaService.getFromSchemaService(any())).thenReturn(someSchema);
InOrder inOrder = inOrder(schemaService); InOrder inOrder = inOrder(schemaService);
...@@ -169,9 +169,9 @@ public class SchemaProviderImplTest { ...@@ -169,9 +169,9 @@ public class SchemaProviderImplTest {
assertEquals(recordSchemaResponse, someSchema); assertEquals(recordSchemaResponse, someSchema);
inOrder.verify(schemaService).getSchema(any()); inOrder.verify(schemaService).getSchema(any());
inOrder.verify(schemaService).getFromStorageService(any()); inOrder.verify(schemaService).getFromSchemaService(any());
verify(schemaService, times(0)).getFromSchemaService(any()); verify(schemaService, times(1)).getFromSchemaService(any());
verify(schemaService, times(1)).getFromStorageService(any()); verify(schemaService, times(0)).getFromStorageService(any());
} }
} }
\ No newline at end of file