-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Edited the file long name strategy adjusted * Modified the filename naming strategy for cache files * Wrote Unit Test and also a bit changed java file * Add Parameterized Tests * Refactored CachingContentProviderBase * Recfactored, setted Logik * minor test impoprvements, added double underscores between parts of original url and the hash * adopted user guide --------- Co-authored-by: ohecker <8004361+ohecker@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
103 additions
and
8 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
53 changes: 53 additions & 0 deletions
53
.../test/java/com/devonfw/tools/solicitor/common/content/CachingContentProviderBaseTest.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,53 @@ | ||
package com.devonfw.tools.solicitor.common.content; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Collection; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Unit test for the {@link CachingContentProviderBase#getKey(String)} method. | ||
*/ | ||
class CachingContentProviderBaseTest { | ||
|
||
// Dummy implementation of CachingContentProviderBase for testing | ||
static class TestCachingContentProvider extends CachingContentProviderBase<Content> { | ||
public TestCachingContentProvider() { | ||
|
||
super(null, null); // ContentFactory and ContentProvider not needed for this test | ||
} | ||
|
||
@Override | ||
protected Collection<String> getCacheUrls(String key) { | ||
|
||
return null; | ||
} | ||
} | ||
|
||
@Test | ||
void shouldGenerateCorrectKeyForUrlOfLength250() { | ||
|
||
TestCachingContentProvider cachingContentProvider = new TestCachingContentProvider(); | ||
|
||
// Create a URL of length 250 (classical logic should be used) | ||
String longUrl250 = "http://example.com/clear/and/concise/url/for/testing/purposes/with/exactly/250/characters/in/total/including/letters/numbers/special/characters/as/appropriate/for/clarity/this/is/a/very/long/url/the/maximum/filename/length/just/to/reach/to/length/250"; | ||
String longResult250 = cachingContentProvider.getKey(longUrl250); | ||
assertTrue(longResult250.length() == 250, // length should be unchanged | ||
"Modified filename length exceeds the maximum for URL of length 250"); | ||
} | ||
|
||
@Test | ||
void shouldGenerateCorrectKeyForUrlOfLength251() { | ||
|
||
TestCachingContentProvider cachingContentProvider = new TestCachingContentProvider(); | ||
|
||
// Create a URL of length 251 (new approach should be used) | ||
String longUrl251 = "http://example.com/clear/and/concise/url/for/testing/purposes/with/exactly/251/characters/in/total/including/letters/numbers/special/characters/as/appropriate/for/clarity/this/is/a/very/long/url/the/maximum/filenames/length/just/to/reach/to/length/251"; | ||
String longResult251 = cachingContentProvider.getKey(longUrl251); | ||
assertEquals(40 + 2 + 64 + 2 + 40, longResult251.length(), | ||
"Modified filename length is incorrect for URL of length 251"); | ||
} | ||
|
||
} |
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