Skip to content

Commit

Permalink
(#101) Created tests, added classes and configuration for external DB…
Browse files Browse the repository at this point in the history
…MS related autotests.
  • Loading branch information
rocket-3 committed Oct 25, 2021
1 parent 6b58dd2 commit 67bb30f
Show file tree
Hide file tree
Showing 24 changed files with 920 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .rultor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
image: g4s8/rultor:alpine3.10
architect:
- rocket-3
assets:
pgSecret.txt: rocket-3/dbgit-test#pgSecret.txt
gitSecret.txt: rocket-3/dbgit-test#gitSecret.txt
merge:
script: |-
pdd -f /dev/null
Expand Down
14 changes: 13 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@
<artifactId>cactoos</artifactId>
<version>0.50</version>
</dependency>

<dependency>
<groupId>com.amihaiemil.web</groupId>
<artifactId>eo-yaml</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.llorllale</groupId>
<artifactId>cactoos-matchers</artifactId>
<version>0.25</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand All @@ -144,6 +148,14 @@
test
</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.5</version>
<scope>
runtime
</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/

/**
* Postgres DBMS's objects, constructed from different sources.
*/
package org.fusionsoft.database.snapshot.objects.dbms.postgres;
36 changes: 36 additions & 0 deletions src/main/java/org/fusionsoft/lib/ci/credentials/Credentials.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.ci.credentials;

/**
* The interface representing any simple Credentials.
* @since 0.1
*/
public interface Credentials {

/**
* Username string.
* @return The string.
*/
String username();

/**
* Password string.
* @return The string.
*/
String password();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.ci.credentials;

import java.nio.file.Path;
import java.util.List;
import org.cactoos.Text;
import org.cactoos.list.ListOf;
import org.cactoos.text.Split;
import org.cactoos.text.TextOf;

/**
* The type of {@link Credentials} that can be constructed of file.
* @since 0.1
*/
public class CredentialsFromFile extends CredentialsOfScalar {

/**
* Instantiates a new Credentials from file.
* @param lines The List of Text to be encapsulated.
*/
private CredentialsFromFile(final List<Text> lines) {
super(() -> new SimpleCredentials(
lines.get(0).asString().trim(),
lines.get(1).asString().trim()
));
}

/**
* Instantiates a new Credentials from file.
* @param path The Path to be encapsulated.
*/
public CredentialsFromFile(final Path path) {
this(
new ListOf<Text>(
new Split(
new TextOf(path),
"\n"
)
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.ci.credentials;

import org.cactoos.text.Joined;
import org.fusionsoft.lib.exception.ValueNotFoundException;

/**
* The type of {@link Credentials} that can be constructed of.
* @since 0.1
*/
public class CredentialsFromProperties extends CredentialsOfScalar {

/**
* Instantiates a new Credentials from properties.
* @param propuser The properties key with username to be encapsulated.
* @param proppassword The properties key with password to be encapsulated.
*/
public CredentialsFromProperties(final String propuser, final String proppassword) {
super(() -> {
final String usr = System.getProperty(propuser);
final String pwd = System.getProperty(proppassword);
if (usr == null || usr.isEmpty() || pwd == null || pwd.isEmpty()) {
throw new ValueNotFoundException(
new Joined(",", propuser, proppassword).asString(),
"System.props"
);
}
return new SimpleCredentials(usr, pwd);
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.ci.credentials;

import org.cactoos.Scalar;
import org.cactoos.scalar.Sticky;
import org.cactoos.scalar.Unchecked;

/**
* The type of {@link Credentials} of {@link Scalar} delegate.
* @since 0.1
*/
public class CredentialsOfScalar implements Credentials {

/**
* The Unchecked Scalar of Credentials encapsulated.
*/
private final Unchecked<Credentials> scalar;

/**
* Instantiates a new Credentials envelope.
* @param scalar The Scalar of Credentials to be encapsulated.
*/
public CredentialsOfScalar(final Scalar<Credentials> scalar) {
this.scalar = new Unchecked<>(
new Sticky<>(
scalar
)
);
}

@Override
public final String username() {
return this.scalar.value().username();
}

@Override
public final String password() {
return this.scalar.value().password();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.lib.ci.credentials;

/**
* The type of {@link Credentials} that can be constructed of text values.
* @since 0.1
*/
public class SimpleCredentials implements Credentials {

/**
* The String encapsulated.
*/
private final String name;

/**
* The String encapsulated.
*/
private final String pwd;

/**
* Instantiates a new Simple credentials.
* @param username The String to be encapsulated.
* @param password The String to be encapsulated.
*/
public SimpleCredentials(final String username, final String password) {
this.name = username;
this.pwd = password;
}

@Override
public final String username() {
return this.name;
}

@Override
public final String password() {
return this.pwd;
}

}
21 changes: 21 additions & 0 deletions src/main/java/org/fusionsoft/lib/ci/credentials/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/

/**
* The package for {@link org.fusionsoft.lib.ci.credentials.Credentials}
* iface and implementations.
*/
package org.fusionsoft.lib.ci.credentials;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (C) 2018-2021 FusionSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied.
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
package org.fusionsoft.database.ci;

import org.cactoos.text.TextEnvelope;
import org.cactoos.text.TextOfScalar;

/**
* The {@link org.cactoos.Text} of url of pg v.11 test instance.
* @since 0.1
*/
public class UrlOfPgTestDatabaseV11 extends TextEnvelope {

/**
* Instantiates a new Url of pg test database v 11.
*/
public UrlOfPgTestDatabaseV11() {
super(new TextOfScalar(() -> "jdbc:postgresql://135.181.94.98:31107/"));
}

}
Loading

0 comments on commit 67bb30f

Please sign in to comment.