Skip to content
Snippets Groups Projects
Commit ddd74137 authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

Merge branch 'master' into search_on_tags

parents 9247b97f cc161d39
No related branches found
No related tags found
1 merge request!92Add support for indexing tags meta-attribute
......@@ -32,6 +32,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
/**
* Provides implementation of the client service that retrieves schemas from the Schema Service
......@@ -58,13 +59,9 @@ public class SchemaProviderImpl implements SchemaService {
@Override
public String getSchema(String kind) throws URISyntaxException, UnsupportedEncodingException {
String schemaFromStorageService = getFromStorageService(kind);
String schemaServiceSchema = getFromSchemaService(kind);
if (schemaFromStorageService != null) {
return schemaFromStorageService;
}
return getFromSchemaService(kind);
return Objects.nonNull(schemaServiceSchema) ? schemaServiceSchema : getFromStorageService(kind);
}
protected String getFromSchemaService(String kind) throws UnsupportedEncodingException, URISyntaxException {
......
......@@ -136,7 +136,7 @@ public class SchemaProviderImplTest {
}
@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";
SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class);
......@@ -148,20 +148,20 @@ public class SchemaProviderImplTest {
assertNull(recordSchemaResponse);
inOrder.verify(schemaService).getSchema(any());
inOrder.verify(schemaService).getFromStorageService(any());
inOrder.verify(schemaService).getFromSchemaService(any());
inOrder.verify(schemaService).getFromStorageService(any());
verify(schemaService, times(1)).getFromStorageService(any());
verify(schemaService, times(1)).getFromSchemaService(any());
}
@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";
SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class);
when(schemaService.getSchema(any())).thenCallRealMethod();
String someSchema = "some schema";
when(schemaService.getFromStorageService(any())).thenReturn(someSchema);
when(schemaService.getFromSchemaService(any())).thenReturn(someSchema);
InOrder inOrder = inOrder(schemaService);
......@@ -169,9 +169,9 @@ public class SchemaProviderImplTest {
assertEquals(recordSchemaResponse, someSchema);
inOrder.verify(schemaService).getSchema(any());
inOrder.verify(schemaService).getFromStorageService(any());
verify(schemaService, times(0)).getFromSchemaService(any());
verify(schemaService, times(1)).getFromStorageService(any());
inOrder.verify(schemaService).getFromSchemaService(any());
verify(schemaService, times(1)).getFromSchemaService(any());
verify(schemaService, times(0)).getFromStorageService(any());
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment