Skip to content

Commit

Permalink
Merge pull request #454 from driver733/fix/blinking-tests
Browse files Browse the repository at this point in the history
fix/blinking-tests
  • Loading branch information
driver733 committed May 26, 2020
2 parents 8cd1a96 + 2253a45 commit 31890e7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 98 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ jobs:
git fetch origin +refs/heads/${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }} --no-tags
git checkout ${{ github.head_ref }}
git checkout ${{ github.base_ref }}
git config --global user.name 'Mikhail Yakushin'
git config --global user.email 'driver733@gmail.com'
git merge ${{ github.head_ref }}
- run: mvn install qulice:check -DskipITs --errors --batch-mode
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.16.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
Expand Down
155 changes: 57 additions & 98 deletions src/test/java/com/driver733/vkuploader/post/PostableRootDirTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import net.jcip.annotations.NotThreadSafe;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.assertj.core.api.Assertions;
import org.junit.Test;

/**
* Test for {@link PostableRootDir}.
*
* @since 0.2
* @checkstyle AnonInnerLengthCheck (2000 lines)
* @checkstyle JavadocMethodCheck (2000 lines)
* @checkstyle ClassDataAbstractionCouplingCheck (2000 lines)
* @checkstyle MethodLength (2000 lines)
* @checkstyle IndentationCheck (1000 lines)
* @since 0.2
*/
@Immutable
@NotThreadSafe
Expand All @@ -64,7 +63,7 @@ public final class PostableRootDirTest extends AbstractVkUnitTest {
"PMD.NonStaticInitializer",
"PMD.AvoidDuplicateLiterals",
"PMD.ProhibitPlainJunitAssertionsRule"
})
})
public void testPhotoAlbum() throws Exception {
final Path root = Paths.get("src/test/resources/photos/");
root.resolve("testPhotoAlbum")
Expand Down Expand Up @@ -194,9 +193,7 @@ public void testPhotoAlbum() throws Exception {
AbstractVkUnitTest.GROUP_ID
)
).post();
TimeUnit.SECONDS.sleep(2);
MatcherAssert.assertThat(
"The properties files differ",
Assertions.assertThat(
new PropsFile(
root.resolve("testPhotoAlbum")
.resolve("vkmu.properties")
Expand All @@ -207,45 +204,20 @@ public void testPhotoAlbum() throws Exception {
Map.Entry::getKey,
Map.Entry::getValue
)
),
Matchers.allOf(
Matchers.hasEntry(
"1.jpg", "1"
),
Matchers.hasEntry(
"2.jpg", "1"
),
Matchers.hasEntry(
"3.jpg", "1"
),
Matchers.hasEntry(
"4.jpg", "1"
),
Matchers.hasEntry(
"5.jpg", "1"
),
Matchers.hasEntry(
"6.jpg", "1"
),
Matchers.hasEntry(
"7.jpg", "1"
),
Matchers.hasEntry(
"8.jpg", "1"
),
Matchers.hasEntry(
"9.jpg", "1"
),
Matchers.hasEntry(
"10.jpg", "1"
),
Matchers.hasEntry(
"11.jpg", "1"
),
Matchers.hasEntry(
"12.jpg", "1"
)
)
).containsOnly(
Assertions.entry("1.jpg", "1"),
Assertions.entry("2.jpg", "1"),
Assertions.entry("3.jpg", "1"),
Assertions.entry("4.jpg", "1"),
Assertions.entry("5.jpg", "1"),
Assertions.entry("6.jpg", "1"),
Assertions.entry("7.jpg", "1"),
Assertions.entry("8.jpg", "1"),
Assertions.entry("9.jpg", "1"),
Assertions.entry("10.jpg", "1"),
Assertions.entry("11.jpg", "1"),
Assertions.entry("12.jpg", "1")
);
}

Expand All @@ -255,7 +227,7 @@ public void testPhotoAlbum() throws Exception {
"PMD.NonStaticInitializer",
"PMD.AvoidDuplicateLiterals",
"PMD.ProhibitPlainJunitAssertionsRule"
})
})
public void testMusicAlbum() throws Exception {
final Path root = Paths.get("src/test/resources/music/");
root.resolve("vkmu.properties")
Expand Down Expand Up @@ -321,9 +293,9 @@ public void testMusicAlbum() throws Exception {
"\"user_id\" : 4356,",
"\"sizes\" : [",
"{",
"\"src\": \"src\",",
"\"width\": 100,",
"\"height\": 100",
"\"src\": \"src\",",
"\"width\": 100,",
"\"height\": 100",
"}",
"],",
"\"photo_75\" : \"url1.com\",",
Expand Down Expand Up @@ -419,9 +391,7 @@ public void testMusicAlbum() throws Exception {
AbstractVkUnitTest.GROUP_ID
)
).post();
TimeUnit.SECONDS.sleep(2);
MatcherAssert.assertThat(
"The properties files differ",
Assertions.assertThat(
new PropsFile(
root.resolve("album")
.resolve("vkmu.properties")
Expand All @@ -432,11 +402,10 @@ public void testMusicAlbum() throws Exception {
Map.Entry::getKey,
Map.Entry::getValue
)
),
Matchers.allOf(
Matchers.hasEntry("test.mp3", "2_123456789"),
Matchers.hasEntry("testMissingTags.mp3", "2_123456789")
)
)
).containsOnly(
Assertions.entry("test.mp3", "2_123456789"),
Assertions.entry("testMissingTags.mp3", "2_123456789")
);
}

Expand All @@ -446,7 +415,7 @@ public void testMusicAlbum() throws Exception {
"PMD.NonStaticInitializer",
"PMD.AvoidDuplicateLiterals",
"PMD.ProhibitPlainJunitAssertionsRule"
})
})
public void testRandomPhoto() throws Exception {
final Path root = Paths.get("src/test/resources/random/");
root.resolve("testPhotoAlbum")
Expand Down Expand Up @@ -563,8 +532,7 @@ public void testRandomPhoto() throws Exception {
root.resolve("testPhotoAlbum")
)
).post();
MatcherAssert.assertThat(
"The properties files differ",
Assertions.assertThat(
new PropsFile(
root.resolve("testPhotoAlbum")
.resolve("vkmu.properties")
Expand All @@ -575,14 +543,13 @@ public void testRandomPhoto() throws Exception {
Map.Entry::getKey,
Map.Entry::getValue
)
),
Matchers.allOf(
Matchers.hasEntry("1.jpg", "1"),
Matchers.hasEntry("2.jpg", "1"),
Matchers.hasEntry("3.jpg", "1"),
Matchers.hasEntry("4.jpg", "1"),
Matchers.hasEntry("5.jpg", "1")
)
)
).containsOnly(
Assertions.entry("1.jpg", "1"),
Assertions.entry("2.jpg", "1"),
Assertions.entry("3.jpg", "1"),
Assertions.entry("4.jpg", "1"),
Assertions.entry("5.jpg", "1")
);
}

Expand All @@ -592,7 +559,7 @@ public void testRandomPhoto() throws Exception {
"PMD.NonStaticInitializer",
"PMD.AvoidDuplicateLiterals",
"PMD.ProhibitPlainJunitAssertionsRule"
})
})
public void testRandomAudio() throws Exception {
final Path root = Paths.get("src/test/resources/random/");
root.resolve("musicAlbum")
Expand Down Expand Up @@ -695,9 +662,7 @@ public void testRandomAudio() throws Exception {
AbstractVkUnitTest.GROUP_ID
)
).post();
TimeUnit.SECONDS.sleep(2);
MatcherAssert.assertThat(
"The properties files differ",
Assertions.assertThat(
new PropsFile(
root.resolve("musicAlbum")
.resolve("vkmu.properties")
Expand All @@ -708,11 +673,10 @@ public void testRandomAudio() throws Exception {
Map.Entry::getKey,
Map.Entry::getValue
)
),
Matchers.allOf(
Matchers.hasEntry("test.mp3", "2_123456789"),
Matchers.hasEntry("testMissingTags.mp3", "2_123456789")
)
)
).containsOnly(
Assertions.entry("test.mp3", "2_123456789"),
Assertions.entry("testMissingTags.mp3", "2_123456789")
);
}

Expand All @@ -722,7 +686,7 @@ public void testRandomAudio() throws Exception {
"PMD.NonStaticInitializer",
"PMD.AvoidDuplicateLiterals",
"PMD.ProhibitPlainJunitAssertionsRule"
})
})
public void testRandomAudioAndPhoto() throws Exception {
final Path root = Paths.get("src/test/resources/random/");
root.resolve("vkmu.properties")
Expand Down Expand Up @@ -888,31 +852,26 @@ public void testRandomAudioAndPhoto() throws Exception {
root.resolve("musicAlbum")
)
).post();
MatcherAssert.assertThat(
"The properties files differ",
Assertions.assertThat(
new PropsFile(
root.resolve("vkmu.properties")
).entrySet()
.stream()
.collect(
Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue
)
),
Matchers.allOf(
Matchers.anyOf(
Matchers.hasEntry("1.jpg", "1"),
Matchers.hasEntry("2.jpg", "1"),
Matchers.hasEntry("3.jpg", "1"),
Matchers.hasEntry("4.jpg", "1"),
Matchers.hasEntry("5.jpg", "1")
),
Matchers.anyOf(
Matchers.hasEntry("test.mp3", "2_123456789"),
Matchers.hasEntry("testMissingTags.mp3", "2_123456789")
Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue
)
)
)
).containsAnyOf(
Assertions.entry("1.jpg", "1"),
Assertions.entry("2.jpg", "1"),
Assertions.entry("3.jpg", "1"),
Assertions.entry("4.jpg", "1"),
Assertions.entry("5.jpg", "1")
).containsAnyOf(
Assertions.entry("test.mp3", "2_123456789"),
Assertions.entry("testMissingTags.mp3", "2_123456789")
);
}

Expand Down

0 comments on commit 31890e7

Please sign in to comment.