Skip to content

Conversation

@Nefarious46
Copy link
Contributor

Contains the following features and objects.

  • ImportSQL
  • Media objects for handling log_group, stream and host
  • SQL objects for Host and Capture
  • SQLMedia object to print querys using jOOQ
  • Changed object attributes to method input parameters

@Nefarious46 Nefarious46 added the enhancement New feature or request label Mar 26, 2025
@Nefarious46 Nefarious46 requested a review from eemhu March 26, 2025 10:13
@Nefarious46 Nefarious46 requested a review from eemhu March 27, 2025 08:33
eemhu
eemhu previously approved these changes Mar 27, 2025
@Nefarious46 Nefarious46 self-assigned this Apr 2, 2025
Copy link
Member

@kortemik kortemik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a mutable pathogen in the code: StringWriter(). please see comments and redesign.

partialCaptureGroupRespons.add(new PartialCaptureGroupResponse(key.asJsonObject()));
}
return partialCaptureResponses;
return partialCaptureGroupRespons;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

partialCaptureGroupRespons -> partialCaptureGroupResponses

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

this.hostRequest = hostRequest;
}

public List<SQLMediaHost> asSQLHosts(final String captureGroupName) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object name SQLHost and methodName asSQLHost are not coherent. is the responsibility design correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to asSqlMediaHosts since it requests hosts for current group and returns them as list of SqlMediaHosts

}

// Gets all the capture and returns a list for sql
public List<SQLMediaCapture> asSQLCaptures(final String captureGroupName) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

object name SQLCapture and method name asSQLCaptures are not coherent. please check the responsibility design. what is the responsibility of SQLCapture?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to asSqlMediaCaptures since it requests captures for current group and returns them as list of SqlMediaCaptures.

if (o == null || getClass() != o.getClass()) {
return false;
}
final Importsql importsql = (Importsql) o;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use name that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

public String asSql() {
final SQLTemplate template = new SQLTemplate();
query.append(template.endTemplate());
return query.toString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do call asSql() two times, what do you get? a mutation i'd guess!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLTemplate removed as a whole.

ApiConfig apiConfig = Assertions.assertDoesNotThrow(() -> new ApiConfig(cfg.asMap()));

SinkRequest fakeRequest = new SinkRequest("flow1", "protocol1", apiConfig);
SinkRequestImpl fakeRequest = new SinkRequestImpl(apiConfig);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use interface instead of implementation for type


SQLStatementMedia expected = sqlMediaExpected.withHost("fake-fqhost", "captureGroup1");

Assertions.assertEquals(expected.asSql(), actual.asSql());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run actual.asSql() once before testing equality

SQLStatementMedia expected = sqlMediaExpected
.withStream("captureGroup1", "fake-index", "fake-sourcetype", "fake-tag");

Assertions.assertEquals(actual.asSql(), expected.asSql());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong order of arguments. first expected, then actual.
run actual.asSql() once before testing equality.

SQLStatementMedia actual = sqlMediaCaptureGroup.asSql(sqlMediaActual);
SQLStatementMedia expected = sqlMediaExpected.withLogGroup("captureGroup1");

Assertions.assertEquals(actual.asSql(), expected.asSql());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong order of arguments. first expected then actual.
run actual.asSql() once before testing equality

Assertions.assertFalse(captureStoragesArray.isEmpty());
// Asserting that contents equal to each other
Assertions.assertEquals(actualCaptureStorageResponse.hashCode(), expectedCaptureStorageResponse.hashCode());
String actual = Assertions.assertDoesNotThrow(() -> importsql.toString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run toString() and see what happens

@Nefarious46 Nefarious46 requested a review from eemhu September 17, 2025 10:33

import com.teragrep.cfe_41.Stored;

public interface CaptureGroup extends Stored {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps the method names here could be simplified:

  • groupName -> name
  • captureGroupType -> type

public List<PartialCaptureResponse> partialCaptureResponses() {
final List<PartialCaptureResponse> partialCaptureResponses = new ArrayList<>();
public List<PartialCaptureGroupResponse> partialCaptureResponses() {
final List<PartialCaptureGroupResponse> partialCaptureGroupResponse = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response -> responses


@Override
public SinkResponse sinkResponse(final String flowName, final String protocolType) throws IOException {
final JsonArray sinksArray = new Response(new RequestData("/sink", apiConfig).doRequest()).asJsonArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this response be validated?

SQLMedia sqlMediaActual = new SQLMedia();
SQLMedia sqlMediaExpected = new SQLMedia();

SQLStatementMedia actual = sqlMediaCaptureGroup.asSql(sqlMediaActual);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the expected values should be hardcoded instead of using the implementations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants