Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/coral/ws-8.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
programmiri authored Jun 24, 2024
2 parents e4285ba + a3fca47 commit 808d9a5
Show file tree
Hide file tree
Showing 3 changed files with 388 additions and 73 deletions.
91 changes: 66 additions & 25 deletions core/src/test/java/io/aiven/klaw/UtilMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import io.aiven.klaw.model.requests.ResetEntityCache;
import io.aiven.klaw.model.requests.SchemaPromotion;
import io.aiven.klaw.model.requests.SchemaRequestModel;
import io.aiven.klaw.model.requests.TeamModel;
import io.aiven.klaw.model.requests.TopicCreateRequestModel;
import io.aiven.klaw.model.requests.TopicUpdateRequestModel;
import io.aiven.klaw.model.requests.UserInfoModel;
Expand Down Expand Up @@ -89,6 +90,8 @@
@Slf4j
public class UtilMethods {

private static final int TEST_TENANT_ID = 101;

public HttpHeaders createHeaders(String username, String password) {
return new HttpHeaders() {
{
Expand All @@ -107,7 +110,7 @@ public List<MessageSchema> getMSchemas() {
mSchema.setSchemaversion("1.0");
mSchema.setTopicname("testtopic");
mSchema.setSchemafull("schema");
mSchema.setTenantId(101);
mSchema.setTenantId(TEST_TENANT_ID);
listMSchemas.add(mSchema);

return listMSchemas;
Expand All @@ -125,7 +128,7 @@ public UserInfoModel getUserInfoMock() {
UserInfoModel userInfo = new UserInfoModel();
userInfo.setUsername("kwusera");
userInfo.setTeamId(101);
userInfo.setTenantId(101);
userInfo.setTenantId(TEST_TENANT_ID);
userInfo.setRole("USER");
userInfo.setMailid("[email protected]");
userInfo.setFullname("My full name");
Expand All @@ -139,7 +142,7 @@ public UserInfoModelResponse getUserInfoMockResponse() {
userInfo.setTeam("Seahorses");
userInfo.setUsername("kwusera");
userInfo.setTeamId(101);
userInfo.setTenantId(101);
userInfo.setTenantId(TEST_TENANT_ID);
userInfo.setRole("USER");
userInfo.setMailid("[email protected]");
userInfo.setFullname("My full name");
Expand All @@ -152,7 +155,7 @@ public UserInfo getUserInfoMockDao() {
UserInfo userInfo = new UserInfo();
userInfo.setTeamId(3);
userInfo.setUsername("kwusera");
userInfo.setTenantId(101);
userInfo.setTenantId(TEST_TENANT_ID);
userInfo.setRole("USER");

return userInfo;
Expand Down Expand Up @@ -180,6 +183,33 @@ public List<UserInfoModelResponse> getUserInfoListModel(String username, String
return userInfoList;
}

public Team getTeamDaoMock() {
ServiceAccounts serviceAccounts = new ServiceAccounts();
serviceAccounts.setNumberOfAllowedAccounts(-1);

Team team = new Team();
team.setTeamname("Seahorses");
team.setTeamId(3);
team.setContactperson("Contact Person");
team.setTenantId(TEST_TENANT_ID);
team.setTeamphone("3142342343242");
team.setTeammail("[email protected]");
team.setApp("app");
team.setRequestTopicsEnvs("1,2,3");
team.setRestrictionsObj("restrictionsObj");
team.setServiceAccounts(serviceAccounts);
team.setOtherParams("otherParams");

return team;
}

public Map<Integer, String> getTenantMapMock() {
Map<Integer, String> tenantMap = new HashMap<>();
tenantMap.put(TEST_TENANT_ID, "testTenantName");

return tenantMap;
}

public List<ActivityLog> getLogs() {
List<ActivityLog> activityLogs = new ArrayList<>();
ActivityLog activityLog = new ActivityLog();
Expand Down Expand Up @@ -216,7 +246,7 @@ public List<Topic> getTopics() {
topicRequest.setTopicname("testtopic");
topicRequest.setTeamId(3);
topicRequest.setNoOfPartitions(1);
topicRequest.setTenantId(101);
topicRequest.setTenantId(TEST_TENANT_ID);
allTopicReqs.add(topicRequest);
return allTopicReqs;
}
Expand Down Expand Up @@ -276,7 +306,7 @@ public List<Acl> getAcls() {
Acl topicRequest = new Acl();
topicRequest.setTeamId(3);
topicRequest.setAclType(AclType.PRODUCER.value);
topicRequest.setTenantId(101);
topicRequest.setTenantId(TEST_TENANT_ID);
allTopicReqs.add(topicRequest);
return allTopicReqs;
}
Expand All @@ -286,13 +316,13 @@ public List<Acl> getSyncAcls() {
Acl acl1 = new Acl();
acl1.setTeamId(102);
acl1.setAclType(AclType.PRODUCER.value);
acl1.setTenantId(101);
acl1.setTenantId(TEST_TENANT_ID);
allTopicReqs.add(acl1);

Acl acl2 = new Acl();
acl2.setTeamId(103);
acl2.setAclType(AclType.CONSUMER.value);
acl2.setTenantId(101);
acl2.setTenantId(TEST_TENANT_ID);
allTopicReqs.add(acl2);

return allTopicReqs;
Expand Down Expand Up @@ -480,7 +510,7 @@ public List<Team> getTeams() {
team.setTeamname("Seahorses");
team.setTeamId(101);
team.setContactperson("Contact Person");
team.setTenantId(101);
team.setTenantId(TEST_TENANT_ID);
team.setTeamphone("3142342343242");
team.setTeammail("[email protected]");

Expand All @@ -500,25 +530,25 @@ public List<Team> getTeamsForTenant() {
List<Team> teams = new ArrayList<>();
Team team1 = new Team();
team1.setTeamname("Seahorses");
team1.setTeamId(101);
team1.setTeamId(104);
team1.setContactperson("Contact Person1");
team1.setTenantId(101);
team1.setTenantId(TEST_TENANT_ID);
team1.setTeamphone("3142342343242");
team1.setTeammail("[email protected]");

Team team2 = new Team();
team2.setTeamname("Octopus");
team2.setTeamId(102);
team2.setContactperson("Contact Person2");
team2.setTenantId(101);
team2.setTenantId(TEST_TENANT_ID);
team2.setTeamphone("3142342343242");
team2.setTeammail("[email protected]");

Team team3 = new Team();
team3.setTeamname("Dragons");
team3.setTeamId(103);
team3.setContactperson("Contact Person3");
team3.setTenantId(101);
team3.setTenantId(TEST_TENANT_ID);
team3.setTeamphone("3142342343242");
team3.setTeammail("[email protected]");

Expand All @@ -537,6 +567,17 @@ public List<TeamModelResponse> getTeamsModel() {
return allTopicReqs;
}

public TeamModel getTeamModelMock() {
TeamModel team = new TeamModel();
team.setTeamname("Seahorses");
team.setContactperson("Contact Person");
team.setTeamphone("314234234");
team.setTenantId(TEST_TENANT_ID);
team.setTeamId(3);
team.setEnvList(List.of("1", "2"));
return team;
}

public List<TopicRequest> getTopicRequests() {
List<TopicRequest> allTopicReqs = new ArrayList<>();
TopicRequest topicRequest = new TopicRequest();
Expand Down Expand Up @@ -567,7 +608,7 @@ public TopicRequest getTopicRequest(int topicId) {
topicRequest.setEnvironment("1");
topicRequest.setRequestOperationType(RequestOperationType.CREATE.value);
topicRequest.setDescription("Test desc");
topicRequest.setTenantId(101);
topicRequest.setTenantId(TEST_TENANT_ID);
return topicRequest;
}

Expand Down Expand Up @@ -622,7 +663,7 @@ public AclRequests getAclRequest(String topicName) {
aclRequest.setAcl_ip("10.11.112.113");
aclRequest.setAclPatternType(AclPatternType.LITERAL.value);
aclRequest.setOtherParams("101");
aclRequest.setTenantId(101);
aclRequest.setTenantId(TEST_TENANT_ID);
return aclRequest;
}

Expand Down Expand Up @@ -686,7 +727,7 @@ public List<SchemaRequest> getSchemaRequestsDao() {
schemaRequest.setTeamId(3);
schemaRequest.setRequestor("kwusera");
schemaRequest.setSchemafull("schema");
schemaRequest.setTenantId(101);
schemaRequest.setTenantId(TEST_TENANT_ID);
schemaList.add(schemaRequest);
return schemaList;
}
Expand All @@ -696,7 +737,7 @@ public KwKafkaConnector getKwKafkaConnector() {
kwKafkaConnector.setConnectorConfig("config");
kwKafkaConnector.setConnectorId(101);
kwKafkaConnector.setConnectorName("testconn");
kwKafkaConnector.setTenantId(101);
kwKafkaConnector.setTenantId(TEST_TENANT_ID);
kwKafkaConnector.setTeamId(1003);
return kwKafkaConnector;
}
Expand Down Expand Up @@ -760,20 +801,20 @@ public List<Env> getEnvLists() {
env.setName("DEV");
envList.add(env);
env.setClusterId(1);
env.setTenantId(101);
env.setTenantId(TEST_TENANT_ID);

Env env2 = new Env();
env2.setId("2");
env2.setName("TST");
env2.setClusterId(2);
env2.setTenantId(101);
env2.setTenantId(TEST_TENANT_ID);
envList.add(env2);

Env env3 = new Env();
env3.setId("3");
env3.setName("PRD");
env3.setClusterId(3);
env3.setTenantId(101);
env3.setTenantId(TEST_TENANT_ID);
envList.add(env3);

return envList;
Expand All @@ -786,7 +827,7 @@ public List<Env> getKafkaEnvs() {
env.setName("DEV");
envList.add(env);
env.setClusterId(1);
env.setTenantId(101);
env.setTenantId(TEST_TENANT_ID);
env.setAssociatedEnv(new EnvTag("3", "DEV"));
return envList;
}
Expand All @@ -796,7 +837,7 @@ public Env getSchemaEnv() {
env.setId("3");
env.setName("DEV");
env.setClusterId(3);
env.setTenantId(101);
env.setTenantId(TEST_TENANT_ID);
env.setAssociatedEnv(new EnvTag("1", "DEV"));

return env;
Expand Down Expand Up @@ -1185,7 +1226,7 @@ public List<Topic> generateTopics(String... topicNames) {
for (int i = 0; i < topicNames.length; i++) {
Topic topic = new Topic();
topic.setTopicname(topicNames[i]);
topic.setTenantId(101);
topic.setTenantId(TEST_TENANT_ID);
topic.setTopicid(i);
topic.setTeamId(10);
topic.setNoOfReplicas("3");
Expand All @@ -1198,7 +1239,7 @@ public List<Topic> generateTopics(String... topicNames) {

public ResetEntityCache getResetEntityCache() {
return ResetEntityCache.builder()
.tenantId(101)
.tenantId(TEST_TENANT_ID)
.entityType(EntityType.USERS.name())
.entityValue("testuser")
.operationType(MetadataOperationType.CREATE.name())
Expand All @@ -1208,7 +1249,7 @@ public ResetEntityCache getResetEntityCache() {
public List<KwTenants> getTenants() {
List<KwTenants> kwTenantsList = new ArrayList<>();
KwTenants kwTenants = new KwTenants();
kwTenants.setTenantId(101);
kwTenants.setTenantId(TEST_TENANT_ID);
kwTenants.setTenantName("default");
kwTenantsList.add(kwTenants);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ private SchemaRequest getSchemasReq() {
SchemaRequest schReq = new SchemaRequest();
schReq.setEnvironment("3");
schReq.setRequestStatus(RequestStatus.CREATED.value);
schReq.setTeamId(101);
schReq.setTeamId(104);
schReq.setRequesttime(new Timestamp(System.currentTimeMillis()));
schReq.setTopicname("testtopic");

Expand Down
Loading

0 comments on commit 808d9a5

Please sign in to comment.