Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
arjun4084346 committed Nov 22, 2024
1 parent 03808f0 commit 11090e6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.ArgumentMatchers.longThat;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.atMost;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
Expand Down Expand Up @@ -502,6 +487,9 @@ public void methodSetUp() throws Exception {
localVeniceWriter = getVeniceWriter(new MockInMemoryProducerAdapter(inMemoryLocalKafkaBroker));

mockStorageEngineRepository = mock(StorageEngineRepository.class);
storeInfo = mock(StoreInfo.class, RETURNS_DEEP_STUBS);
when(storeInfo.getHybridStoreConfig().getRealTimeTopicName())
.thenReturn(storeNameWithoutVersionInfo + Version.REAL_TIME_TOPIC_SUFFIX);

mockLogNotifier = mock(LogNotifier.class);
mockNotifierProgress = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import static com.linkedin.venice.kafka.protocol.enums.MessageType.PUT;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

import com.linkedin.venice.controller.kafka.protocol.admin.AdminOperation;
import com.linkedin.venice.controller.kafka.protocol.admin.SchemaMeta;
Expand Down Expand Up @@ -118,7 +117,7 @@ public void testAdminToolConsumption() {
when(schemaResponse.getSchemaStr()).thenReturn(SCHEMA_STRING);
when(controllerClient.getKeySchema(STORE_NAME)).thenReturn(schemaResponse);
StoreResponse storeResponse = mock(StoreResponse.class);
StoreInfo storeInfo = mock(StoreInfo.class);
StoreInfo storeInfo = mock(StoreInfo.class, RETURNS_DEEP_STUBS);
when(storeInfo.getPartitionCount()).thenReturn(2);
when(controllerClient.getStore(STORE_NAME)).thenReturn(storeResponse);
when(storeResponse.getStore()).thenReturn(storeInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ public void testHeartbeatSenderCreation() {
// Prepare controller client.
ControllerClient controllerClient = mock(ControllerClient.class);
StoreResponse storeResponse = mock(StoreResponse.class);
StoreInfo storeInfo = mock(StoreInfo.class);
StoreInfo storeInfo = mock(StoreInfo.class, RETURNS_DEEP_STUBS);
PartitionerConfig partitionerConfig = new PartitionerConfigImpl();
doReturn(Utils.composeRealTimeTopic(heartbeatStoreName)).when(storeInfo)
.getHybridStoreConfig()
.getRealTimeTopicName();
when(storeInfo.getHybridStoreConfig().getRealTimeTopicName())
.thenReturn(Utils.composeRealTimeTopic(heartbeatStoreName));
doReturn(1).when(storeInfo).getPartitionCount();
doReturn(partitionerConfig).when(storeInfo).getPartitionerConfig();
doReturn(storeInfo).when(storeResponse).getStore();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ public BufferReplayPolicy getBufferReplayPolicy() {

@Override
public String getRealTimeTopicName() {
return this.hybridConfig.realTimeTopicName == null ? null : this.hybridConfig.realTimeTopicName.toString();
return this.hybridConfig == null || this.hybridConfig.realTimeTopicName == null
? null
: this.hybridConfig.realTimeTopicName.toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.linkedin.venice.controller;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

import com.linkedin.venice.authorization.AuthorizerService;
import com.linkedin.venice.authorization.DefaultIdentityParser;
Expand Down Expand Up @@ -111,10 +108,10 @@ public void setupInternalMocks() {

personaRepository = mock(StoragePersonaRepository.class);

store = mock(Store.class);
store = mock(Store.class, RETURNS_DEEP_STUBS);
doReturn(OfflinePushStrategy.WAIT_N_MINUS_ONE_REPLCIA_PER_PARTITION).when(store).getOffLinePushStrategy();
doReturn(false).when(store).isMigrating();
doReturn("test_real_time_topic_rt").when(store.getHybridStoreConfig()).getRealTimeTopicName();
when(store.getHybridStoreConfig().getRealTimeTopicName()).thenReturn("test_real_time_topic_rt");
doReturn(store).when(internalAdmin).checkPreConditionForAclOp(any(), any());

HelixReadWriteStoreRepository storeRepository = mock(HelixReadWriteStoreRepository.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package com.linkedin.venice.controller.kafka;

import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -104,7 +94,7 @@ public void setUp() {

when(admin.getStore(any(), anyString())).thenAnswer(invocation -> {
String requestedStoreName = invocation.getArgument(1); // Capture the storeName argument
Store mockStore = mock(Store.class);
Store mockStore = mock(Store.class, RETURNS_DEEP_STUBS);
when(mockStore.getHybridStoreConfig().getRealTimeTopicName())
.thenReturn(requestedStoreName + Version.REAL_TIME_TOPIC_SUFFIX);
return mockStore;
Expand Down

0 comments on commit 11090e6

Please sign in to comment.