Skip to content

Commit

Permalink
(#106) Fix ObjectsFromServerTest, fix Qulice's warnings, added equals…
Browse files Browse the repository at this point in the history
…, hashCode implementations at some base classes.
  • Loading branch information
rocket-3 committed Jan 9, 2022
1 parent 195200d commit 136a422
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public DataObjectOfMappingAndTable(
final DbdDataMapping mapping,
final DbObject<DbdTableMapping> table
) {
this(mapping, new ObjectNameOfScalar(()->table.signature().name()));
this(mapping, new ObjectNameOfScalar(() -> table.signature().name()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import org.fusionsoft.database.snapshot.DbObject;

/**
* The {@link DataObjectOfMappingAndTable} with {@link InlineRowsDataMappingOfConnection}, can be constructed of
* {@link Connection} and parent {@link DbObject} of {@link DbdTableMapping}.
* The {@link DataObjectOfMappingAndTable} with {@link InlineRowsDataMappingOfConnection},
* can be constructed of {@link Connection} and parent {@link DbObject} of {@link DbdTableMapping}.
* @since 0.1
*/
public class InlineRowsDataObjectOfConnection extends DataObjectOfMappingAndTable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,19 @@ public final YamlNode asYaml() {
return this.object.asYaml();
}

@Override
public final boolean equals(final Object other) {
return this.object.equals(other);
}

@Override
public final int hashCode() {
return this.object.hashCode();
}

@Override
public final String toString() {
return this.object.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import com.amihaiemil.eoyaml.YamlMapping;
import java.text.MessageFormat;
import org.cactoos.text.Repeated;
import org.cactoos.text.UncheckedText;
import org.fusionsoft.database.SimpleYamlRepresentative;
import org.fusionsoft.database.snapshot.DbObject;
import org.fusionsoft.database.snapshot.ObjectSignature;
Expand Down Expand Up @@ -52,10 +54,13 @@ public final ObjectSignature signature() {

@Override
public final String toString() {
final int length = 10;
return MessageFormat.format(
"\n= = = =\n{0}\n- - - -\n{1}",
"\n{2}\n{0}\n{3}\n{1}",
this.sig.asString(),
this.asYaml().toString()
this.asYaml().toString(),
new UncheckedText(new Repeated("= ", length)).asString(),
new UncheckedText(new Repeated("- ", length)).asString()
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ public interface ObjectType<T extends YamlNode> extends Text {
*/
String asString();

/**
* Equality of types.
* @param other The other {@link ObjectType}.
* @return The boolean.
*/
boolean equalsTo(ObjectType<?> other);

}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public final ObjectType<?> type() {
@Override
public final String asString() {
return MessageFormat.format(
"{1} {0}",
"{0}: {1}",
new UncheckedText(this.name()).asString(),
new UncheckedText(this.type()).asString()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.fusionsoft.database.snapshot.objects.signature.type;

import com.amihaiemil.eoyaml.YamlNode;
import java.util.Objects;
import org.cactoos.Func;
import org.cactoos.func.UncheckedFunc;
import org.fusionsoft.database.snapshot.objects.signature.ObjectType;
Expand Down Expand Up @@ -57,4 +58,25 @@ public final String asString() {
return this.text;
}

@Override
public final boolean equalsTo(final ObjectType<?> other) {
return this.asString().equals(other.asString());
}

@Override
public final boolean equals(final Object other) {
boolean equal = false;
if (this == other) {
equal = true;
} else if (other instanceof ObjectType) {
equal = this.equalsTo((SimpleObjectType<?>) other);
}
return equal;
}

@Override
public final int hashCode() {
return Objects.hash(this.text);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
package org.fusionsoft.database.snapshot.objects;

import org.cactoos.iterable.Filtered;
import org.cactoos.scalar.And;
import org.cactoos.scalar.Unchecked;
import org.cactoos.set.SetOf;
import org.fusionsoft.database.mapping.MappingOfExampleYaml;
import org.fusionsoft.database.mapping.dbd.DbdRootMapping;
import org.fusionsoft.database.snapshot.DbObject;
import org.fusionsoft.database.snapshot.objects.ofdbd.ObjectsOfDbdRootMapping;
import org.fusionsoft.database.snapshot.objects.signature.type.ObjectTypeTable;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasSize;
import org.llorllale.cactoos.matchers.HasValuesMatching;

/**
* The test for {@link ObjectsOfDbdRootMapping} class.
Expand All @@ -40,25 +38,39 @@ class ObjectsOfDbdRootMappingTest {
*/
@Test
public void getsFourTablesOfExampleYaml() {
Assertions.assertTrue(
new Unchecked<>(
new And(
new Filtered<>(
o -> o.signature().type().equals(new ObjectTypeTable()),
new ObjectsOfDbdRootMapping(
new DbdRootMapping(
new MappingOfExampleYaml()
)
)
),
(Iterable<DbObject<?>> itrb) -> new SetOf<>(itrb).size() == 4,
(Iterable<DbObject<?>> itrb) -> new And(
item -> !item.asYaml().toString().isEmpty(),
itrb
).value()
new Assertion<>(
"Should get 4 tables of example DBD yaml",
new Filtered<>(
o -> o.signature().type().equals(new ObjectTypeTable()),
new ObjectsOfDbdRootMapping(
new DbdRootMapping(
new MappingOfExampleYaml()
)
)
).value()
);
),
new HasSize(4)
).affirm();
}

/**
* Returns four tables of example yaml.
*/
@Test
public void getsCorrectTablesOfExampleYaml() {
new Assertion<>(
"Should get non-empty tables of example DBD yaml",
new Filtered<>(
o -> o.signature().type().equals(new ObjectTypeTable()),
new ObjectsOfDbdRootMapping(
new DbdRootMapping(
new MappingOfExampleYaml()
)
)
),
new HasValuesMatching<>(
val -> !val.asYaml().toString().isEmpty()
)
).affirm();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

import com.amihaiemil.eoyaml.YamlMapping;
import java.io.File;
import java.util.Comparator;
import org.cactoos.Text;
import org.cactoos.iterable.IterableOf;
import org.cactoos.iterable.Mapped;
import org.cactoos.iterable.Sorted;
import org.cactoos.map.MapOf;
import org.cactoos.text.TextOf;
import org.fusionsoft.database.Folder;
Expand Down Expand Up @@ -65,7 +67,7 @@ class ObjectsFromServerTest {
*/
@Test
public void worksWithPagilla() {
final int size = 171;
final int size = 174;
new Assertion<>(
"Has expected object list size from 'pagilla' database",
new ObjectsFromServer(
Expand Down Expand Up @@ -158,12 +160,12 @@ public void createsCorrectDbd() {
}

/**
* Show me.
* Show me individual object's data.
*/
@Test
@Disabled
@SuppressWarnings("PMD")
public void showMe() {
public void showIndividual() {
for (final DbObject<? extends YamlMapping> object : new ObjectsFromServer(
new DbdServerMappingWithCredentials(
new UrlOfPgGitLabDatabaseV11(this.database),
Expand All @@ -174,6 +176,26 @@ public void showMe() {
}
}

/**
* Show me the names only.
*/
@Test
@Disabled
@SuppressWarnings("PMD")
public void showNames() {
for (final DbObject<? extends YamlMapping> object : new Sorted<>(
Comparator.comparing(x -> x.signature().name().asString()),
new ObjectsFromServer(
new DbdServerMappingWithCredentials(
new UrlOfPgGitLabDatabaseV11(this.database),
new CredsOfPgTestDatabase()
)
)
)) {
System.out.println(object.signature().asString());
}
}

/**
* The Dbd created can be rendered.
*/
Expand Down

8 comments on commit 136a422

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 101-03d56aec disappeared from src/main/java/org/fusionsoft/database/snapshot/objects/dbms/postgres/PgData.java, that's why I closed #106. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 106-65328a04 discovered in src/main/java/org/fusionsoft/database/snapshot/data/ValueFormat.java and submitted as #132. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 106-752434a9 discovered in src/main/java/org/fusionsoft/database/snapshot/data/ValueFormatNumber.java and submitted as #133. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 40-bf76a7ed discovered in src/main/java/org/fusionsoft/database/snapshot/query/pg/PgIndexesQuery.java and submitted as #134. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 40-e1ce631e discovered in src/main/java/org/fusionsoft/database/snapshot/objects/signature/type/ObjectTypeUser.java and submitted as #135. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 40-8c586603 discovered in src/main/java/org/fusionsoft/database/snapshot/objects/signature/type/ObjectTypeTablespace.java and submitted as #136. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

Puzzle 40-cab96508 discovered in src/main/java/org/fusionsoft/database/snapshot/objects/signature/type/ObjectTypeRole.java and submitted as #137. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link

@0pdd 0pdd commented on 136a422 Jan 9, 2022

Choose a reason for hiding this comment

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

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

POST https://api.github.com/repos/rocket-3/dbmss/issues: 403 - You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. // See: https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits

Please, copy and paste this stack trace to GitHub:

Octokit::Forbidden
POST https://api.github.com/repos/rocket-3/dbmss/issues: 403 - You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. // See: https://docs.github.com/rest/overview/resources-in-the-rest-api#secondary-rate-limits
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/response/raise_error.rb:14:in `on_complete'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/middleware.rb:19:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/response.rb:59:in `on_complete'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/middleware.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/middleware/follow_redirects.rb:73:in `perform_with_redirection'
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/middleware/follow_redirects.rb:61:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/request/retry.rb:148:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/rack_builder.rb:154:in `build_response'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/connection.rb:516:in `run_request'
/app/vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/connection.rb:281:in `post'
/app/vendor/bundle/ruby/2.6.0/gems/sawyer-0.8.2/lib/sawyer/agent.rb:94:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/connection.rb:156:in `request'
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/connection.rb:28:in `post'
/app/vendor/bundle/ruby/2.6.0/gems/octokit-4.20.0/lib/octokit/client/issues.rb:102:in `create_issue'
/app/objects/github_tickets.rb:47:in `submit'
/app/objects/milestone_tickets.rb:39:in `submit'
/app/objects/logged_tickets.rb:50:in `submit'
/app/objects/github_tagged_tickets.rb:40:in `submit'
/app/objects/commit_tickets.rb:38:in `submit'
/app/objects/emailed_tickets.rb:35:in `submit'
/app/objects/sentry_tickets.rb:46:in `submit'
/app/objects/puzzles.rb:89:in `block in expose'
/app/objects/puzzles.rb:80:in `loop'
/app/objects/puzzles.rb:80:in `expose'
/app/objects/puzzles.rb:33:in `deploy'
/app/objects/job.rb:38:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:357:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `block in compile!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1032:in `route_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1061:in `block in process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1011:in `block in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `each'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1129:in `block in dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1124:in `dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `block in call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:929:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:246:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:216:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1991:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1769:in `synchronize'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

Please sign in to comment.