И что валидатору не нравитьтся...
уже мозг сломал,
тест проходит
В методе testHashMapStorage должно быть выполнено сравнение времени получения множества ключей и множества значений для стратегий HashMapStorageStrategy и HashBiMapStorageStrategy.
Set<Long> ids = new HashSet<>();
Assert.assertTrue(timeWhithHashMapIds > timeWhithHashBiMapIds);
Assert.assertNotEquals(timeWhithHashMapStrings, timeWhithHashBiMapStrings,30);
public class SpeedTest extends Assert {
public long getTimeForGettingIds(Shortener shortener, Set<String> strings, Set<Long> ids) {
Long startTime = System.nanoTime()/ 1000;
strings.forEach(str -> ids.add(shortener.getId(str)));
Long endTime = System.nanoTime()/ 1000;
return endTime - startTime;
}
public long getTimeForGettingStrings(Shortener shortener, Set<Long> ids, Set<String> strings) {
Long startTime = System.nanoTime()/ 1000;
ids.forEach(id -> strings.add(shortener.getString(id)));
Long endTime = System.nanoTime()/ 1000;
return endTime - startTime;
}
@Test
public void testHashMapStorage() {
Shortener shortener1 = new Shortener(new HashMapStorageStrategy());
Shortener shortener2 = new Shortener(new HashBiMapStorageStrategy());
Set<String> origStrings = new HashSet<>();
for (int i = 0; i < 10000; i++) {
origStrings.add(Helper.generateRandomString());
}
Set<Long> ids = new HashSet<>();
Long timeWhithHashMapIds= getTimeForGettingIds(shortener1, origStrings, ids);
Long timeWhithHashMapStrings = getTimeForGettingStrings(shortener1,ids,new HashSet<String>());
Set<Long> idsBi = new HashSet<>();
Long timeWhithHashBiMapIds = getTimeForGettingIds(shortener2, origStrings,idsBi);
Long timeWhithHashBiMapStrings = getTimeForGettingStrings(shortener1,idsBi,new HashSet<String>());
Assert.assertTrue(timeWhithHashMapIds > timeWhithHashBiMapIds);
Assert.assertNotEquals(timeWhithHashMapStrings, timeWhithHashBiMapStrings,30);
}
}
package com.javarush.task.task33.task3310;
import java.util.ArrayList;
public class test {
public static void main(String[] args) {
String s = null;
System.out.println(s.length());
}
}