-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
779 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ADirectory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class ADirectory extends QualityComposition<Path> | ||
{ | ||
public ADirectory() | ||
{ | ||
super(new Satisfies<>(Files::isDirectory, file -> new Text("not a directory"), new Text("a directory"))); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/AFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class AFile extends QualityComposition<Path> | ||
{ | ||
public AFile() | ||
{ | ||
super(new Satisfies<>(Files::isRegularFile, file -> new Text("not a file"), new Text("a file"))); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/ContainsText.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.Quality; | ||
import org.saynotobugs.confidence.description.Spaced; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.description.Value; | ||
import org.saynotobugs.confidence.quality.composite.DescribedAs; | ||
import org.saynotobugs.confidence.quality.composite.Has; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.EqualTo; | ||
|
||
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class ContainsText extends QualityComposition<Path> | ||
{ | ||
public ContainsText(String text) | ||
{ | ||
this(new EqualTo<>(text)); | ||
} | ||
|
||
public ContainsText(Quality<? super CharSequence> mDelegate) | ||
{ | ||
this(StandardCharsets.UTF_8, mDelegate); | ||
} | ||
|
||
public ContainsText(Charset charset, Quality<? super CharSequence> delegate) | ||
{ | ||
super(new Has<>( | ||
new Text("contains"), | ||
new Text("contained"), | ||
path -> new String(Files.readAllBytes(path), charset), | ||
new DescribedAs<>(orig -> new Spaced(new Value(charset.name()), new Text("text"), orig), delegate))); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/Exists.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class Exists extends QualityComposition<Path> | ||
{ | ||
public Exists() | ||
{ | ||
super(new Satisfies<>(Files::exists, file -> new Text("does not exist"), new Text("exists"))); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/HasName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.Quality; | ||
import org.saynotobugs.confidence.quality.composite.Has; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.EqualTo; | ||
|
||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class HasName extends QualityComposition<Path> | ||
{ | ||
public HasName(CharSequence name) | ||
{ | ||
this(new EqualTo<>(name)); | ||
} | ||
|
||
public HasName(Quality<? super CharSequence> nameQuality) | ||
{ | ||
super(new Has<>("name", path -> path.getFileName().toString(), nameQuality)); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/HasParent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.Quality; | ||
import org.saynotobugs.confidence.quality.composite.Has; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.EqualTo; | ||
|
||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class HasParent extends QualityComposition<Path> | ||
{ | ||
public HasParent(Path parent) | ||
{ | ||
this(new EqualTo<>(parent)); | ||
} | ||
|
||
public HasParent(Quality<? super Path> parentQuality) | ||
{ | ||
super(new Has<>("parent", Path::getParent, parentQuality)); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/Readable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class Readable extends QualityComposition<Path> | ||
{ | ||
public Readable() | ||
{ | ||
super(new Satisfies<>(Files::isReadable, file -> new Text("not readable"), new Text("readable"))); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
confidence-core/src/main/java/org/saynotobugs/confidence/quality/path/Writeable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2024 dmfs GmbH | ||
* | ||
* | ||
* 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.saynotobugs.confidence.quality.path; | ||
|
||
import org.dmfs.srcless.annotations.staticfactory.StaticFactories; | ||
import org.saynotobugs.confidence.description.Text; | ||
import org.saynotobugs.confidence.quality.composite.QualityComposition; | ||
import org.saynotobugs.confidence.quality.object.Satisfies; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
@StaticFactories( | ||
value = "Path", | ||
packageName = "org.saynotobugs.confidence.core.quality") | ||
public final class Writeable extends QualityComposition<Path> | ||
{ | ||
public Writeable() | ||
{ | ||
super(new Satisfies<>(Files::isWritable, file -> new Text("not writeable"), new Text("writeable"))); | ||
} | ||
} |
Oops, something went wrong.