-
Notifications
You must be signed in to change notification settings - Fork 4
Importsql v2 #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Importsql v2 #41
Conversation
src/test/java/com/teragrep/cfe_41/captureGroup/PartialCaptureResponseTest.java
Show resolved
Hide resolved
kortemik
left a comment
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partialCaptureGroupRespons -> partialCaptureGroupResponses
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use name that
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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
|
|
||
| import com.teragrep.cfe_41.Stored; | ||
|
|
||
| public interface CaptureGroup extends Stored { |
There was a problem hiding this comment.
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<>(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
Contains the following features and objects.