src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
SecretsGroupInfo { public SecretsGroupInfo(SecretsGroupSRN srn, Optional<String> encryptorArn, Optional<String> storageArn, Optional<String> adminPolicyArn, Optional<String> readOnlyPolicyArn, List<Principal> admin, List<Principal> readOnly) { this.srn = srn; this.encryptorArn = encryptorArn; this.storageArn = storageA... | @Test public void testSecretsGroupInfo() { List<Principal> readonlyPrincipals = getReadOnlyPrincipals(); List<Principal> adminPrincipals = getAdminPrincipals(); SecretsGroupInfo info = new SecretsGroupInfo( new SecretsGroupSRN(account, new SecretsGroupIdentifier(groupRegion, groupName)), encryptorArn, storageArn, admin... |
SecretsGroupInfo { @Override public boolean equals(final Object obj) { if(obj instanceof SecretsGroupInfo){ final SecretsGroupInfo other = (SecretsGroupInfo) obj; return Objects.equal(srn, other.srn) && Objects.equal(encryptorArn, other.encryptorArn) && Objects.equal(storageArn, other.storageArn) && Objects.equal(admin... | @Test public void testEquals() { SecretsGroupInfo info = new SecretsGroupInfo( new SecretsGroupSRN(account, new SecretsGroupIdentifier(groupRegion, groupName)), encryptorArn, storageArn, adminArn, readonlyArn, new ArrayList<>(), new ArrayList<>()); SecretsGroupInfo infoCopy = new SecretsGroupInfo( new SecretsGroupSRN(a... |
RoleARN extends ARN { public String getRoleName() { return this.resource; } RoleARN(final String arn); String getRoleName(); } | @Test public void role() { RoleARN arn = new RoleARN("arn:aws:iam::12345:role/role-name"); assertThat(arn.getRoleName(), is("role-name")); } |
SecretValue implements BestEffortShred { @Override public boolean equals(final Object obj) { if (obj instanceof SecretValue) { final SecretValue other = (SecretValue) obj; return Arrays.equals(secretValue, other.asByteArray()) && Objects.equal(type, other.type) && Objects.equal(encoding, other.encoding); } else { retur... | @Test public void testEquals() { byte[] value1 = {1, 2, 3, 4}; byte[] value2 = {1, 2, 3, 4}; byte[] value3 = {1, 2, 3, 5}; SecretValue secretValue1 = new SecretValue(value1, SecretType.OPAQUE); SecretValue secretValue2 = new SecretValue(value2, SecretType.OPAQUE); SecretValue secretValue3 = new SecretValue(value3, Secr... |
Principal { public static Principal fromArn(String arn, String account) { String[] parts = arn.split(":"); if (parts.length != 6 || !parts[0].equals("arn") || !parts[1].equals("aws") || !parts[2].equals("iam")) { throw new InvalidResourceName(arn, "A principal ARN should start with 'arn:aws:iam' and have 6 parts"); } i... | @Test public void testFromArn() { Principal principal; principal = Principal.fromArn("arn:aws:iam::12345:user/bob", "12345"); assertEquals(principal.type, PrincipalType.USER); assertEquals(principal.name, "bob" ); principal = Principal.fromArn("arn:aws:iam::12345:group/team-awesome", "12345"); assertEquals(principal.ty... |
Principal { @Override public String toString() { return String.format("%s [%s]", name, type.toString()); } Principal(PrincipalType type, String principalName); static Principal fromArn(String arn, String account); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj); final P... | @Test public void testToString() { Principal principal = Principal.fromArn("arn:aws:iam::12345:user/bob", "12345"); assertEquals(principal.toString(), "bob [user]"); } |
Principal { @Override public boolean equals(final Object obj) { if(obj instanceof Principal){ final Principal other = (Principal) obj; return Objects.equal(name, other.name) && Objects.equal(type, other.type); } else{ return false; } } Principal(PrincipalType type, String principalName); static Principal fromArn(String... | @Test public void testEquals() { Principal principal1 = Principal.fromArn("arn:aws:iam::12345:user/bob", "12345"); Principal principal2 = new Principal(PrincipalType.USER, "bob"); assertTrue(principal1.equals(principal2)); } |
SecretEntry implements BestEffortShred { public SecretEntry(EncryptionPayload encryptionPayload, RawSecretEntry rawSecretEntry) { this.secretIdentifier = rawSecretEntry.secretIdentifier; this.version = rawSecretEntry.version; this.state = rawSecretEntry.state; this.notBefore = rawSecretEntry.notBefore; this.notAfter = ... | @Test public void testSecretEntry() { EncryptionPayload payload = createPayload(true); RawSecretEntry rawEntry = createRawEntry(); SecretEntry secretEntry = new SecretEntry(payload, rawEntry); assertEquals(secretEntry.secretIdentifier.name, rawEntry.secretIdentifier.name); assertEquals(secretEntry.version, rawEntry.ver... |
SecretsGroupIdentifier implements Comparable<SecretsGroupIdentifier> { @Override public String toString() { return String.format("%s [%s]", name, region.getName()); } SecretsGroupIdentifier(@JsonProperty("region") Region region,
@JsonProperty("name") String name); @Override String toSt... | @Test public void testConstructWithValidNames() { SecretsGroupIdentifier group = new SecretsGroupIdentifier(Region.US_WEST_1, "project.service.group1"); assertEquals(group.name, "project.service.group1"); assertEquals(group.region, Region.US_WEST_1); assertEquals(group.toString(), "project.service.group1 [us-west-1]");... |
SecretsGroupIdentifier implements Comparable<SecretsGroupIdentifier> { @Override public boolean equals(final Object obj) { if(obj instanceof SecretsGroupIdentifier){ final SecretsGroupIdentifier other = (SecretsGroupIdentifier) obj; return Objects.equal(name, other.name) && Objects.equal(region, other.region); } else {... | @Test public void testEquals() throws Exception { SecretsGroupIdentifier group1 = new SecretsGroupIdentifier(Region.US_WEST_1, "project.service.group1"); SecretsGroupIdentifier group2 = new SecretsGroupIdentifier(Region.US_WEST_1, "project.service.group1"); SecretsGroupIdentifier group3 = new SecretsGroupIdentifier(Reg... |
SecretsGroupIdentifier implements Comparable<SecretsGroupIdentifier> { @Override public int compareTo(SecretsGroupIdentifier o) { if (region.compareTo(o.region) == 0) { return name.compareTo(o.name); } else { return region.compareTo(o.region); } } SecretsGroupIdentifier(@JsonProperty("region") Region region,
... | @Test public void testCompareTo() throws Exception { SecretsGroupIdentifier group1 = new SecretsGroupIdentifier(Region.US_WEST_1, "project.service.group1"); SecretsGroupIdentifier group2 = new SecretsGroupIdentifier(Region.US_WEST_1, "project.service.group1"); SecretsGroupIdentifier group3 = new SecretsGroupIdentifier(... |
SecretIdentifier { @Override public String toString() { return name; } @JsonCreator SecretIdentifier(@JsonProperty("name") String name); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj); final String name; } | @Test public void testConstructWithValidNames() { SecretIdentifier secret = new SecretIdentifier("fooBar1"); assertEquals(secret.name, "fooBar1"); assertEquals(secret.toString(), "fooBar1"); }
@Test public void testConstructWithValidUnderscoreNames() { SecretIdentifier secret = new SecretIdentifier("foo_bar_1"); assert... |
SecretIdentifier { @Override public boolean equals(final Object obj) { if(obj instanceof SecretIdentifier){ final SecretIdentifier other = (SecretIdentifier) obj; return Objects.equal(name, other.name); } else { return false; } } @JsonCreator SecretIdentifier(@JsonProperty("name") String name); @Override String toStri... | @Test public void testEquals() throws Exception { SecretIdentifier secret1 = new SecretIdentifier("fooBar1"); SecretIdentifier secret2 = new SecretIdentifier("fooBar1"); SecretIdentifier secret3 = new SecretIdentifier("fooBar2"); assertTrue(secret1.equals(secret2)); assertFalse(secret1.equals(secret3)); assertFalse(sec... |
IAMPolicyManager { public void detachAdmin(SecretsGroupIdentifier group, Principal principal) { detachPrincipal(group, principal, AccessLevel.ADMIN); } IAMPolicyManager(AmazonIdentityManagement client, AWSCredentialsProvider awsCredentials, ClientConfiguration clientConfiguration); static IAMPolicyManager fromCredentia... | @Test public void testDetachAdminUser() throws Exception { Principal principal = new Principal(PrincipalType.USER, "alice"); partiallyMockedPolicyManager.detachAdmin(group, principal); DetachUserPolicyRequest request = new DetachUserPolicyRequest() .withPolicyArn(ADMIN_POLICY_ARN) .withUserName(principal.name); verify(... |
LambdaHandler implements RequestStreamHandler { @Override public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException { I inputObject = deserializeEventJson(input, getInputType()); O handlerResult = handleRequest(inputObject, context); serializeOutput(output, handlerResult); } ... | @Test public void handleRequest() throws Exception { String jsonInputAndExpectedOutput = "{\"value\":\"testValue\"}"; InputStream exampleInputStream = new ByteArrayInputStream(jsonInputAndExpectedOutput.getBytes(StandardCharsets.UTF_8)); OutputStream exampleOutputStream = new OutputStream() { private final StringBuilde... |
Handler extends LambdaHandler<AuthorizationInput, AuthorizationOutput> { @Override public AuthorizationOutput handleRequest(AuthorizationInput input, Context context) { final String authenticationToken = input.getAuthorizationToken(); final PolicyDocument policyDocument = new PolicyDocument(); PolicyStatement.Effect po... | @Test public void testFailingToken() throws Exception { Handler testHandler = new Handler(); AuthorizationInput mockEvent = createNiceMock(AuthorizationInput.class); expect(mockEvent.getAuthorizationToken()).andReturn("INVALID_TOKEN").anyTimes(); replay(mockEvent); AuthorizationOutput authorizationOutput = testHandler.... |
UserServiceImpl implements UserService { @Override public User registerNewUser(String username, String email) throws UserRegistrationException { checkEmailValidity(email); checkEmailUniqueness(email); checkUsernameUniqueness(username); User newUser = new User() .setId(UUID.randomUUID().toString()) .setUsername(username... | @Test public void failedUserRegistrationWithExistingUsernameTest() throws Exception { thrown.expect(AnotherUserWithSameUsernameExistsException.class); UserService userService = getUserService(); final String username = UUID.randomUUID() + "test-username"; userService.registerNewUser(username, UUID.randomUUID() + "@test... |
DataTypes { public static <T extends Number> T parseNum(String num, Class<T> cls, T def) { if (num == null) { return def; } T result = def; String toParse = num; Long multiplier = 1L; try { switch (num.charAt(num.length() - 1)) { case 'k' : case 'K' : multiplier = 1024L; toParse = num.substring(0, num.length() - 1); br... | @Test public void testParseNum() { assertEquals( new Long( 262144L ), Long.valueOf( Integer.class.cast( DataTypes.parseNum( "256k", Integer.class, 1 ) ) ) ); assertEquals( new Long( 262144L ), Long.class.cast( DataTypes.parseNum( "256k", Long.class, 1L ) ) ); assertEquals( new Double( 670720.0D ), Double.class.cast( Da... |
MobileV3 extends AnnotatedXMPPProcessor implements XMPPProcessorIfc, XMPPPacketFilterIfc { @Override @SuppressWarnings("unchecked") public void filter(Packet _packet, XMPPResourceConnection sessionFromSM, NonAuthUserRepository repo, Queue<Packet> results) { if ((sessionFromSM == null) ||!sessionFromSM.isAuthorized() ||... | @Test public void testRecipientEnabledFor2ResourcesPresence() throws TigaseStringprepException, NotAuthorizedException { String recipient = "recipient-1@localhost"; JID recp1 = JID.jidInstanceNS(recipient + "/res1"); JID recp2 = JID.jidInstanceNS(recipient + "/res2"); JID connId1 = JID.jidInstanceNS("c2s@localhost/reci... |
BindResource extends XMPPProcessor implements XMPPProcessorIfc, XMPPPreprocessorIfc { @Override public boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings) { if ((session == null) || session.isServerSession() || !session.isAut... | @Test public void testPreProcess() throws TigaseStringprepException, NotAuthorizedException, NoConnectionIdException { JID senderJid = JID.jidInstance("sender@example.com/res-1"); JID recipientJid = JID.jidInstance("recipient@example.com/res-2"); XMPPResourceConnection senderSession = getSession(JID.jidInstance("c2s@ex... |
C2SDeliveryErrorProcessor { public static boolean preProcess(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings, Message messageProcessor) { if (packet.getElemName() != tigase.server.Message.ELEM_NAME) return false; Element deliveryError = getD... | @Test public void testPreprocessingNotSupportedPackets() throws Exception { Element packetEl = null; Packet packet = null; JID from = JID.jidInstance("from@example.com/res"); JID to = JID.jidInstance("to@example.com"); packetEl = new Element("iq", new String[] { "id", "from", "to" }, new String[] { UUID.randomUUID().to... |
RosterElement { public final void setName(final String name) { if(name==this.name || (name!=null && this.name!=null && name.equals(this.name))){ return ; } else { this.name = name==null?null:XMLUtils.unescape(name); this.modified = true; } } RosterElement(Element roster_el, XMPPResourceConnection session); RosterEleme... | @Test public void testSetName() { RosterElement e = new RosterElement(JID.jidInstanceNS("a@b.c"), null, new String[] {}, null); assertNull(e.getName()); assertTrue(e.isModified()); e.getRosterElement(); assertFalse(e.isModified()); e.setName(null); assertFalse(e.isModified()); assertNull(e.getName()); e.setName("jeff")... |
OfflineMessages extends XMPPProcessor implements XMPPPostprocessorIfc, XMPPProcessorIfc { @Override public void postProcess( final Packet packet, final XMPPResourceConnection conn, final NonAuthUserRepository repo, final Queue<Packet> queue, Map<String, Object> settings ) { if ( conn == null || !message.hasConnectionFo... | @Test public void testStorageOfflineMessageForBareJid() throws Exception { BareJID userJid = BareJID.bareJIDInstance("user1@example.com"); JID res1 = JID.jidInstance(userJid, "res1"); JID res2 = JID.jidInstance(userJid, "res2"); XMPPResourceConnection session1 = getSession(JID.jidInstance("c2s@example.com/" + UUID.rand... |
OfflineMessages extends XMPPProcessor implements XMPPPostprocessorIfc, XMPPProcessorIfc { public Queue<Packet> restorePacketForOffLineUser( XMPPResourceConnection conn, MsgRepositoryIfc repo ) throws UserNotFoundException, NotAuthorizedException { Queue<Element> elems = repo.loadMessagesToJID( conn, true ); if ( elems ... | @Test public void testRestorePacketForOffLineUser() throws Exception { BareJID userJid = BareJID.bareJIDInstance("user1@example.com"); JID res1 = JID.jidInstance(userJid, "res1"); XMPPResourceConnection session1 = getSession(JID.jidInstance("c2s@example.com/" + UUID.randomUUID().toString()), res1); assertEquals(Arrays.... |
DataTypes { public static int parseSizeInt(String size, int def) { return parseNum(size, Integer.class, def); } static T parseNum(String num, Class<T> cls, T def); static int parseSizeInt(String size, int def); static boolean parseBool(final String val); static Object decodeValueType(char typeId, String value); static... | @Test public void testParseSizeInt() { System.out.println( "parseSizeInt" ); assertEquals( 1, DataTypes.parseSizeInt( "1", 1 ) ); assertEquals( 1024, DataTypes.parseSizeInt( "1k", 1 ) ); assertEquals( 1024 * 1024, DataTypes.parseSizeInt( "1m", 1 ) ); assertEquals( 1024 * 1024 * 1024, DataTypes.parseSizeInt( "1g", 1 ) )... |
OfflineMessages extends XMPPProcessor implements XMPPPostprocessorIfc, XMPPProcessorIfc { protected boolean loadOfflineMessages( Packet packet, XMPPResourceConnection conn ) { if ( ( conn == null ) || conn.isAnonymous() ){ return false; } if ( conn.getSessionData( ID ) != null ){ return false; } if (packet.getStanzaTo(... | @Test public void testLoadOfflineMessages() throws Exception { BareJID userJid = BareJID.bareJIDInstance("user1@example.com"); JID res1 = JID.jidInstance(userJid, "res1"); JID res2 = JID.jidInstance(userJid, "res2"); XMPPResourceConnection session1 = getSession(JID.jidInstance("c2s@example.com/" + UUID.randomUUID().toS... |
OfflineMessages extends XMPPProcessor implements XMPPPostprocessorIfc, XMPPProcessorIfc { protected boolean isAllowedForOfflineStorage(Packet pac) { for (ElementMatcher matcher : offlineStorageMatchers) { if (matcher.matches(pac)) return matcher.getValue(); } return isAllowedForOfflineStorageDefaults(pac); } @Override... | @Test public void testIsAllowedForOfflineStorage() throws Exception { Packet packet = Packet.packetInstance(new Element("message", new Element[]{ new Element("body", "Test message") }, new String[] { "from", "to" }, new String[] { "from@example.com/res1", "to@example.com/res2" })); assertTrue(offlineProcessor.isAllowed... |
JabberIqPrivacy extends XMPPProcessor implements XMPPProcessorIfc, XMPPPreprocessorIfc, XMPPPacketFilterIfc { public static Authorization validateList(final XMPPResourceConnection session, final List<Element> items) { Authorization result = null; try { HashSet<Integer> orderSet = new HashSet<Integer>(); HashSet<String>... | @Test public void testValidateListGood() { List<Element> items = new ArrayList<Element>(); Authorization result = null; items.add(new Element("item", new String[] { "type", "value", "action", "order" }, new String[] { "subscription", "both", "allow", "10" })); items.add(new Element("item", new String[] { "action", "ord... |
JabberIqPrivacy extends XMPPProcessor implements XMPPProcessorIfc, XMPPPreprocessorIfc, XMPPPacketFilterIfc { protected boolean allowed(Packet packet, XMPPResourceConnection session) { try { if (allowedByDefault(packet, session)) return true; Element list = Privacy.getActiveList(session); if ((list == null) ) { list = ... | @Test public void testFilterPresenceOut() throws Exception { JID jid = JID.jidInstance("test@example/res-1"); JID connId = JID.jidInstance("c2s@example.com/asdasd"); XMPPResourceConnection session = getSession(connId, jid); Element list = new Element("list", new String[] { "name" }, new String[] { "default" }); Element... |
MessageCarbons extends XMPPProcessor implements XMPPProcessorIfc, XMPPPacketFilterIfc,
XMPPPresenceUpdateProcessorIfc { @Override public void process(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, Map<String, Object> settings) throws XMPPException { if (session == ... | @Test public void testResourceSelectionForMessageDeliveryForBareJid() throws Exception { BareJID userJid = BareJID.bareJIDInstance("user1@example.com"); JID res1 = JID.jidInstance(userJid, "res1"); JID res2 = JID.jidInstance(userJid, "res2"); XMPPResourceConnection session1 = getSession(JID.jidInstance("c2s@example.com... |
SSLContextContainer implements SSLContextContainerIfc { public static <T> T find(Map<String, T> data, String key) { if (data.containsKey(key)) { return data.get(key); } int idx = key.indexOf("."); if (idx >= 0) { String asteriskKey = "*" + key.substring(idx); T value = data.get(asteriskKey); if (value != null) { data.p... | @Test public void testFind() { final HashMap<String, String> domains = new HashMap<String, String>(); domains.put("one.com", "one.com"); domains.put("a.two.com", "a.two.com"); domains.put("*.two.com", "*.two.com"); assertEquals("one.com", SSLContextContainer.find(domains, "one.com")); assertNull(SSLContextContainer.fin... |
Dialback extends S2SAbstractProcessor { @Override public boolean process(Packet p, S2SIOService serv, Queue<Packet> results) { CID cid = (CID) serv.getSessionData().get("cid"); boolean skipTLS = (cid == null) ? false : skipTLSForHost(cid.getRemoteHost()); if (p.getXMLNS() == XMLNS_DB_VAL) { if (log.isLoggable(Level.FIN... | @Test public void testAuthorizationForSingleDomain() throws TigaseStringprepException { Queue<Packet> results = new ArrayDeque<>(); handler = new S2SConnectionHandlerImpl(results); dialback.init(handler, new HashMap()); String key = UUID.randomUUID().toString(); S2SIOService serv = new S2SIOService(); serv.setSessionId... |
WebSocketHybi implements WebSocketProtocolIfc { @Override public boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf) throws NoSuchAlgorithmException, IOException { if (!headers.containsKey(WS_VERSION_KEY)) { return false; } StringBuilder response = new StringBuilder(RESPONSE_HEADE... | @Test public void testHandshakeFail() throws NoSuchAlgorithmException, IOException { final ByteBuffer tmp = ByteBuffer.allocate(2048); WebSocketXMPPIOService<Object> io = new WebSocketXMPPIOService<Object>(new WebSocketProtocolIfc[]{ new WebSocketHixie76() }) { @Override protected void writeBytes(ByteBuffer data) { tmp... |
WebSocketXMPPIOService extends XMPPIOService<RefObject> { protected int parseHttpHeaders(byte[] buf, Map<String, String> headers) { int i = 0; while (buf[i] != '\n') { i++; } i++; if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, "parsing request = \n{0}", new String(buf)); } StringBuilder builder = new StringB... | @Test public void testHttpHeadersParsingWithSpaces() throws UnsupportedEncodingException { byte[] data = prepareHTTPRequest(headers, true); Map<String, String> parsedHeaders = new HashMap<>(); service.parseHttpHeaders(data, parsedHeaders); assertMaps(headers, parsedHeaders); }
@Test public void testHttpHeadersParsingWi... |
WebSocketHixie76 implements WebSocketProtocolIfc { @Override public boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf) throws NoSuchAlgorithmException, IOException { if (headers.containsKey(WS_VERSION_KEY)) { return false; } byte[] secBufArr = new byte[16]; Long secKey1 = decodeH... | @Test public void testHandshakeOK() throws NoSuchAlgorithmException, IOException { final ByteBuffer tmp = ByteBuffer.allocate(2048); WebSocketXMPPIOService<Object> io = new WebSocketXMPPIOService<Object>(new WebSocketProtocolIfc[]{ new WebSocketHixie76() }) { @Override protected void writeBytes(ByteBuffer data) { tmp.p... |
JDBCRepository implements AuthRepository, UserRepository { @Override public String getData(BareJID user_id, final String subnode, final String key, final String def) throws UserNotFoundException, TigaseDBException { try { long nid = getNodeNID(null, user_id, subnode); if (log.isLoggable(Level.FINEST)) { log.log( Level.... | @Test public void testGetData() throws InterruptedException { System.out.println( "repo: " + repo ); if ( repo != null ){ LocalDateTime localNow = LocalDateTime.now(); long initalDelay = 5; ScheduledExecutorService scheduler = Executors.newScheduledThreadPool( 10 ); final int iter = 50; final int threads = 10; for ( in... |
ClusterElement { public String getMethodName() { return method_name; } ClusterElement(Element elem); ClusterElement(JID from, JID to, StanzaType type, Packet packet); static Element clusterElement(JID from, JID to, StanzaType type); static Element createClusterElement(JID from, JID to, StanzaType type,
String pac... | @Test @SuppressWarnings("deprecation") public void testGetMethodName() { SimpleParser parser = new SimpleParser(); DomBuilderHandler handler = new DomBuilderHandler(); char[] data = "<cluster to=\"sess-man@blue\" type=\"set\" id=\"cl-6627\" xmlns=\"tigase:cluster\" from=\"sess-man@green\"><control><visited-nodes><node-... |
ClusterConnectionSelector implements ClusterConnectionSelectorIfc { @Override public XMPPIOService<Object> selectConnection(Packet p, ClusterConnection conn) { if (conn == null) return null; int code = Math.abs(handler.hashCodeForPacket(p)); List<XMPPIOService<Object>> conns = conn.getConnections(); if (conns.size() > ... | @Test public void testSelectConnection() throws Exception { ClusterConnection conn = new ClusterConnection("test"); ClusterConnectionSelector selector = new ClusterConnectionSelector(); selector.setClusterConnectionHandler(new ClusterConnectionHandler() { @Override public int hashCodeForPacket(Packet packet) { return p... |
CustomDomainFilter { public static Set<Rule> parseRules( String rules ) throws ParseException { String[] rulesArr = rules.split( ";" ); if ( rulesArr != null ){ return parseRules( rulesArr ); } return null; } private CustomDomainFilter(); static Set<Rule> parseRules( String rules ); static Set<Rule> parseRules( String... | @Test public void testParseRules() throws TigaseStringprepException, ParseException { System.out.println( "parseRules" ); Set<Rule> expResult = new TreeSet<>(); Rule rule = new Rule( 1, true, RuleType.self, null ); if ( rule != null ){ expResult.add( rule ); } rule = new Rule( 2, true, RuleType.jid, JID.jidInstance( "a... |
CustomDomainFilter { public static boolean isAllowed( JID source, JID destination, String rules ) { try { Set<Rule> parseRules = parseRules( rules ); if ( parseRules != null ){ return isAllowed( source, destination, parseRules ); } else { return true; } } catch ( ParseException e ) { return true; } } private CustomDom... | @Test public void testIsAllowed() throws TigaseStringprepException, ParseException { JID jid1_r1 = JID.jidInstance( "user1", "domain1", "resource1" ); JID jid1_r2 = JID.jidInstance( "user1", "domain1", "resource2" ); JID jid2_r1 = JID.jidInstance( "user2", "domain1", "resource1" ); JID jid3_r1 = JID.jidInstance( "user3... |
NodeNameUtil { public static String createNodeName(String eventName, String xmlns) { return (eventName == null ? "*" : eventName) + "|" + (xmlns == null ? "*" : xmlns); } private NodeNameUtil(); static String createNodeName(String eventName, String xmlns); static EventName parseNodeName(String nodeName); } | @Test public void testCreateNodeName() throws Exception { assertEquals("1|2", NodeNameUtil.createNodeName("1", "2")); assertEquals("*|2", NodeNameUtil.createNodeName(null, "2")); assertEquals("*|*", NodeNameUtil.createNodeName(null, null)); assertEquals("1|*", NodeNameUtil.createNodeName("1", null)); } |
NodeNameUtil { public static EventName parseNodeName(String nodeName) { int i = nodeName.indexOf('|'); String n = nodeName.substring(0, i); String x = nodeName.substring(i + 1); return new EventName(n.equals("*") ? null : n, x.equals("*") ? null : x); } private NodeNameUtil(); static String createNodeName(String event... | @Test public void testParseNodeName() throws Exception { assertEquals(new EventName("1", "2"), NodeNameUtil.parseNodeName("1|2")); assertEquals(new EventName(null, "2"), NodeNameUtil.parseNodeName("*|2")); assertEquals(new EventName(null, null), NodeNameUtil.parseNodeName("*|*")); assertEquals(new EventName("1", null),... |
EventName { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; EventName other = (EventName) obj; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (xmlns... | @Test public void testEquals() throws Exception { assertEquals(new EventName(null, null), new EventName(null, null)); assertEquals(new EventName(null, "2"), new EventName(null, "2")); assertEquals(new EventName("1", "2"), new EventName("1", "2")); assertNotEquals(new EventName(null, null), new EventName("2", "2")); ass... |
ImageResizer { public byte[] resize(BufferedImage originalImage) throws IOException { if (originalImage == null) { throw new IIOException("Image is null. Did ImageIO fail to decode the image?"); } BufferedImage resized = ImageUtil.resizeImage(originalImage, size, size); originalImage.flush(); byte[] resizedBytes = com.... | @Test(expected = IIOException.class) public void testResizeNullImage() throws Exception { cut.resize((BufferedImage) null); } |
OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getByHash(long hash) throws RepositoryException { try { return imageDao.queryForMatching(new ImageRecord(null, hash)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } OrmliteImageRepository... | @Test public void testGetByHashNotFound() throws Exception { assertThat(cut.getByHash(HASH_NEW_RECORD), hasSize(0)); }
@Test public void testGetByHashExists() throws Exception { assertThat(cut.getByHash(HASH_EXISTING_RECORD), containsInAnyOrder(imageExisting)); } |
OrmliteImageRepository implements ImageRepository { @Override public ImageRecord getByPath(Path path) throws RepositoryException { try { return imageDao.queryForId(path.toString()); } catch (SQLException e) { throw new RepositoryException("Failed to query for path", e); } } OrmliteImageRepository(Dao<ImageRecord, Strin... | @Test public void testGetByPathExists() throws Exception { assertThat(cut.getByPath(Paths.get(pathExisting)), is(imageExisting)); }
@Test public void testGetByPathNotFound() throws Exception { assertThat(cut.getByPath(Paths.get(pathNew)), is(nullValue())); } |
OrmliteImageRepository implements ImageRepository { @Override public synchronized List<ImageRecord> startsWithPath(Path directory) throws RepositoryException { argStartsWithPath.setValue(directory.toString() + STRING_QUERY_WILDCARD); try { return imageDao.query(queryStartsWithPath); } catch (SQLException e) { throw new... | @Test public void testStartsWithPath() throws Exception { assertThat(cut.startsWithPath(Paths.get("exi")), containsInAnyOrder(imageExisting)); } |
OrmliteImageRepository implements ImageRepository { @Override public void remove(ImageRecord image) throws RepositoryException { try { imageDao.delete(image); } catch (SQLException e) { throw new RepositoryException("Failed to remove image", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRe... | @Test public void testRemoveImageRecord() throws Exception { cut.remove(imageExisting); assertThat(imageDao.queryForMatching(imageExisting), hasSize(0)); }
@Test public void testRemoveImageRecordCollection() throws Exception { imageDao.create(imageNew); List<ImageRecord> toRemove = new LinkedList<ImageRecord>(); toRemo... |
OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getAll() throws RepositoryException { try { return imageDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query all", e); } } OrmliteImageRepository(Dao<ImageRecord, String> imageDao, Dao<IgnoreRe... | @Test public void testGetAll() throws Exception { imageDao.create(imageNew); assertThat(cut.getAll(), containsInAnyOrder(imageExisting, imageNew)); } |
OrmliteImageRepository implements ImageRepository { @Override public List<ImageRecord> getAllWithoutIgnored() throws RepositoryException { try { return imageDao.query(queryNotIgnored); } catch (SQLException e) { throw new RepositoryException("Failed to query for non-ignored", e); } } OrmliteImageRepository(Dao<ImageRec... | @Test public void testGetAllWithoutIgnored() throws Exception { imageDao.create(imageNew); List<ImageRecord> result = cut.getAllWithoutIgnored(); assertThat(result, hasItem(imageNew)); assertThat(result, hasSize(1)); }
@Test public void testGetAllWithoutIgnoredPath() throws Exception { imageDao.create(imageNew); List<I... |
ExtendedAttribute implements ExtendedAttributeQuery { public static void setExtendedAttribute(Path path, String name, String value) throws IOException { setExtendedAttribute(path, name, StandardCharsets.US_ASCII.encode(value)); } static String createName(String... names); static boolean supportsExtendedAttributes(Path... | @Test public void testSetExtendedAttributePathStringString() throws Exception { ExtendedAttribute.setExtendedAttribute(tempFile, TEST_NAME, TEST_VALUE); } |
OrmliteTagRepository implements TagRepository { @Override public synchronized Tag getByName(String name) throws RepositoryException { try { nameArg.setValue(name); return tagDao.queryForFirst(nameQuery); } catch (SQLException e) { throw new RepositoryException("Failed to query by name", e); } } OrmliteTagRepository(Dao... | @Test public void testGetByName() throws Exception { Tag result = cut.getByName(TAG_EXSTING); assertThat(result, is(tagExsting)); } |
OrmliteTagRepository implements TagRepository { @Override public void store(Tag tag) throws RepositoryException { try { tagDao.createOrUpdate(tag); } catch (SQLException e) { throw new RepositoryException("Failed to store", e); } } OrmliteTagRepository(Dao<Tag, Long> tagDao); @Override synchronized Tag getByName(String... | @Test public void testStore() throws Exception { cut.store(tagNew); Tag result = cut.getByName(TAG_NEW); assertThat(result, is(tagNew)); }
@Test(expected = RepositoryException.class) public void testStoreDuplicate() throws Exception { cut.store(tagNew); cut.store(new Tag(TAG_NEW)); } |
OrmliteTagRepository implements TagRepository { @Override public void remove(Tag tag) throws RepositoryException { try { tagDao.delete(tag); } catch (SQLException e) { throw new RepositoryException("Failed to delete", e); } } OrmliteTagRepository(Dao<Tag, Long> tagDao); @Override synchronized Tag getByName(String name)... | @Test public void testRemove() throws Exception { cut.remove(tagExsting); Tag result = cut.getByName(TAG_EXSTING); assertThat(result, is(nullValue())); } |
OrmliteTagRepository implements TagRepository { @Override public List<Tag> getAll() throws RepositoryException { try { return tagDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query all", e); } } OrmliteTagRepository(Dao<Tag, Long> tagDao); @Override synchronized Tag getByName(St... | @Test public void testGetAll() throws Exception { List<Tag> results = cut.getAll(); assertThat(results, containsInAnyOrder(tagContext, tagExsting)); } |
OrmliteTagRepository implements TagRepository { @Override public List<Tag> getWithContext() throws RepositoryException { try { return tagDao.queryForMatching(new Tag(null, true)); } catch (SQLException e) { throw new RepositoryException("Failed to query by context flag", e); } } OrmliteTagRepository(Dao<Tag, Long> tagD... | @Test public void testGetWithContext() throws Exception { List<Tag> results = cut.getWithContext(); assertThat(results, containsInAnyOrder(tagContext)); } |
OrmliteFilterRepository implements FilterRepository { @Override public List<FilterRecord> getByHash(long hash) throws RepositoryException { try { return filterDao.queryForMatching(new FilterRecord(hash, null, null)); } catch (SQLException e) { throw new RepositoryException("Failed to query by hash", e); } } OrmliteFilt... | @Test public void testGetByHash() throws Exception { List<FilterRecord> filters = cut.getByHash(HASH_TWO); assertThat(filters, containsInAnyOrder(new FilterRecord(HASH_TWO, TAG_TWO, null))); }
@Test(expected = RepositoryException.class) public void testGetByHashException() throws Exception { deleteFilterTable(); cut.ge... |
OrmliteFilterRepository implements FilterRepository { @Override public List<FilterRecord> getByTag(Tag tag) throws RepositoryException { try { return filterDao.queryForMatchingArgs(new FilterRecord(0, tag, null)); } catch (SQLException e) { throw new RepositoryException("Failed to query by tag", e); } } OrmliteFilterRe... | @Test public void testGetByTag() throws Exception { List<FilterRecord> filters = cut.getByTag(TAG_ONE); assertThat(filters, containsInAnyOrder(new FilterRecord(HASH_ONE, TAG_ONE, null))); }
@Test(expected = RepositoryException.class) public void testGetByTagException() throws Exception { deleteFilterTable(); cut.getByT... |
ExtendedAttribute implements ExtendedAttributeQuery { public static String readExtendedAttributeAsString(Path path, String name) throws IOException { ByteBuffer buffer = readExtendedAttribute(path, name); return StandardCharsets.US_ASCII.decode(buffer).toString(); } static String createName(String... names); static bo... | @Test public void testReadExtendedAttributeAsString() throws Exception { ExtendedAttribute.setExtendedAttribute(tempFile, TEST_NAME, TEST_VALUE); assertThat(ExtendedAttribute.readExtendedAttributeAsString(tempFile, TEST_NAME), is(TEST_VALUE)); } |
OrmliteFilterRepository implements FilterRepository { @Override public List<FilterRecord> getAll() throws RepositoryException { try { return filterDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to get all filters", e); } } OrmliteFilterRepository(Dao<FilterRecord, Integer> filterDao... | @Test public void testGetAll() throws Exception { List<FilterRecord> filters = cut.getAll(); assertThat(filters, containsInAnyOrder(allFilters.toArray(new FilterRecord[0]))); }
@Test(expected = RepositoryException.class) public void testGetAllException() throws Exception { deleteFilterTable(); cut.getAll(); } |
OrmliteFilterRepository implements FilterRepository { @Override public void store(FilterRecord toStore) throws RepositoryException { if (toStore.hasThumbnail()) { checkAndCreateThumbnail(toStore); } try { if (filterDao.queryForMatchingArgs(toStore).isEmpty()) { filterDao.create(toStore); } } catch (SQLException e) { th... | @Test(expected = RepositoryException.class) public void testStoreThumbnailException() throws Exception { TableUtils.dropTable(cs, Thumbnail.class, false); cut.store(new FilterRecord(HASH_NEW_THUMBNAIL, TAG_ONE, newThumbnail)); }
@Test(expected = RepositoryException.class) public void testStoreFilterException() throws E... |
OrmliteFilterRepository implements FilterRepository { @Override public void remove(FilterRecord filter) throws RepositoryException { try { filterDao.delete(filter); } catch (SQLException e) { throw new RepositoryException("Failed to remove Filter", e); } } OrmliteFilterRepository(Dao<FilterRecord, Integer> filterDao, D... | @Test public void testRemove() throws Exception { FilterRecord toRemove = allFilters.get(0); cut.remove(toRemove); assertThat(cut.getAll(), not(hasItem(toRemove))); } |
OrmliteIgnoreRepository implements IgnoreRepository { @Override public void store(IgnoreRecord toStore) throws RepositoryException { try { ignoreDao.createIfNotExists(toStore); } catch (SQLException e) { throw new RepositoryException("Failed to store ignore", e); } } OrmliteIgnoreRepository(Dao<IgnoreRecord, String> ig... | @Test public void testStoreNew() throws Exception { cut.store(newIgnore); assertThat(dao.queryForAll(), hasItem(newIgnore)); }
@Test public void testStoreDuplicate() throws Exception { cut.store(existingIgnore); assertThat(dao.queryForAll(), hasSize(1)); }
@Test public void testStoreNewSize() throws Exception { cut.sto... |
OrmliteIgnoreRepository implements IgnoreRepository { @Override public void remove(IgnoreRecord toRemove) throws RepositoryException { try { ignoreDao.delete(toRemove); } catch (SQLException e) { throw new RepositoryException("Failed to delete ignore", e); } } OrmliteIgnoreRepository(Dao<IgnoreRecord, String> ignoreDao... | @Test public void testRemove() throws Exception { cut.remove(existingIgnore); assertThat(dao.queryForAll(), not(hasItem(existingIgnore))); }
@Test public void testRemoveSize() throws Exception { cut.remove(existingIgnore); assertThat(dao.queryForAll(), is(empty())); } |
ExtendedAttribute implements ExtendedAttributeQuery { public static boolean isExtendedAttributeSet(Path path, String name) throws IOException { return createUserDefinedFileAttributeView(path).list().contains(name); } static String createName(String... names); static boolean supportsExtendedAttributes(Path path); stati... | @Test public void testExtendedAttributeIsNotSet() throws Exception { assertThat(ExtendedAttribute.isExtendedAttributeSet(tempFile, TEST_NAME), is(false)); } |
OrmliteIgnoreRepository implements IgnoreRepository { @Override public IgnoreRecord findByPath(Path path) throws RepositoryException { return findByPath(path.toString()); } OrmliteIgnoreRepository(Dao<IgnoreRecord, String> ignoreDao); @Override void store(IgnoreRecord toStore); @Override void remove(IgnoreRecord toRemo... | @Test public void testFindByPathPath() throws Exception { assertThat(cut.findByPath(toPath(PATH_A)), is(existingIgnore)); }
@Test public void testFindByPathPathNotFound() throws Exception { assertThat(cut.findByPath(toPath(PATH_B)), is(nullValue())); }
@Test public void testFindByPathString() throws Exception { assertT... |
OrmliteIgnoreRepository implements IgnoreRepository { @Override public boolean isPathIgnored(String path) throws RepositoryException { return findByPath(path) != null; } OrmliteIgnoreRepository(Dao<IgnoreRecord, String> ignoreDao); @Override void store(IgnoreRecord toStore); @Override void remove(IgnoreRecord toRemove)... | @Test public void testFindByPathStringNotFound() throws Exception { assertThat(cut.isPathIgnored(PATH_B), is(false)); }
@Test public void testIsPathIgnoredString() throws Exception { assertThat(cut.isPathIgnored(PATH_A), is(true)); }
@Test public void testIsPathIgnoredStringNope() throws Exception { assertThat(cut.isPa... |
OrmliteIgnoreRepository implements IgnoreRepository { @Override public List<IgnoreRecord> getAll() throws RepositoryException { try { return ignoreDao.queryForAll(); } catch (SQLException e) { throw new RepositoryException("Failed to query for all ingored images: " + e.toString(), e); } } OrmliteIgnoreRepository(Dao<Ig... | @Test public void testGetAll() throws Exception { dao.create(newIgnore); assertThat(cut.getAll(), containsInAnyOrder(newIgnore, existingIgnore)); } |
Tag { @Override public final boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Tag)) { return false; } Tag other = (Tag) obj; if (contextMenu != other.contextMenu) { return false; } if (tag == null) { if (other.tag != null) { return false; } } else if... | @Test public void testEquals() throws Exception { EqualsVerifier.forClass(Tag.class).withIgnoredFields("userTagId") .suppress(Warning.NONFINAL_FIELDS).verify();; } |
Tag { public final String getTag() { return tag; } @Deprecated Tag(); Tag(String tag); Tag(String tag, boolean contextMenu); final String getTag(); final void setTag(String tag); final boolean isContextMenu(); boolean isMatchAll(); final void setContextMenu(boolean contextMenu); @Override String toString(); @Overrid... | @Test public void testTagStringName() throws Exception { assertThat(cut.getTag(), is(TEST_TAG)); } |
ExtendedAttribute implements ExtendedAttributeQuery { public static String createName(String... names) { StringBuilder sb = new StringBuilder(SIMILARIMAGE_NAMESPACE); for (String name : names) { sb.append("."); sb.append(name); } return sb.toString(); } static String createName(String... names); static boolean support... | @Test public void testCreateName() throws Exception { assertThat(ExtendedAttribute.createName("foo", "bar"), is(ExtendedAttribute.SIMILARIMAGE_NAMESPACE + ".foo.bar")); } |
Tag { public final boolean isContextMenu() { return contextMenu; } @Deprecated Tag(); Tag(String tag); Tag(String tag, boolean contextMenu); final String getTag(); final void setTag(String tag); final boolean isContextMenu(); boolean isMatchAll(); final void setContextMenu(boolean contextMenu); @Override String toSt... | @Test public void testTagStringContextMenu() throws Exception { assertThat(cut.isContextMenu(), is(false)); } |
Tag { public boolean isMatchAll() { return StringUtil.MATCH_ALL_TAGS.equals(tag); } @Deprecated Tag(); Tag(String tag); Tag(String tag, boolean contextMenu); final String getTag(); final void setTag(String tag); final boolean isContextMenu(); boolean isMatchAll(); final void setContextMenu(boolean contextMenu); @Ove... | @Test public void testIsMatchAll() throws Exception { assertThat(cut.isMatchAll(), is(false)); }
@Test public void testIsMatchAllAsterisk() throws Exception { cut = new Tag(StringUtil.MATCH_ALL_TAGS); assertThat(cut.isMatchAll(), is(true)); } |
SQLiteDatabase implements Database { @Override public ConnectionSource getCs() { return connectionSource; } SQLiteDatabase(); SQLiteDatabase(Path dbPath); SQLiteDatabase(String dbPath); @Override ConnectionSource getCs(); @Override void close(); } | @Test public void testGetCs() throws Exception { assertThat(cut.getCs().isOpen(EMPTY_STRING), is(true)); } |
SQLiteDatabase implements Database { @Override public void close() { connectionSource.closeQuietly(); } SQLiteDatabase(); SQLiteDatabase(Path dbPath); SQLiteDatabase(String dbPath); @Override ConnectionSource getCs(); @Override void close(); } | @Ignore("Closing a closed connection when using pooled connections results in NPE") @Test public void testClose() throws Exception { ConnectionSource cs = cut.getCs(); assertThat(cs.isOpen(EMPTY_STRING), is(true)); cut.close(); assertThat(cs.isOpen(EMPTY_STRING), is(false)); } |
FilterRecord { public long getpHash() { return pHash; } @Deprecated FilterRecord(); FilterRecord(long hash, Tag tag); FilterRecord(long pHash, Tag tag, Thumbnail thumbnail); long getpHash(); void setpHash(long pHash); Tag getTag(); void setTag(Tag tag); Thumbnail getThumbnail(); final void setThumbnail(Thumbnail thu... | @Test public void testGetpHash() throws Exception { assertThat(filterRecord.getpHash(), is(HASH_ONE)); } |
FilterRecord { public void setpHash(long pHash) { this.pHash = pHash; } @Deprecated FilterRecord(); FilterRecord(long hash, Tag tag); FilterRecord(long pHash, Tag tag, Thumbnail thumbnail); long getpHash(); void setpHash(long pHash); Tag getTag(); void setTag(Tag tag); Thumbnail getThumbnail(); final void setThumbna... | @Test public void testSetpHash() throws Exception { assertThat(GUARD_MSG, filterRecord.getpHash(), is(HASH_ONE)); filterRecord.setpHash(HASH_TWO); assertThat(filterRecord.getpHash(), is(HASH_TWO)); } |
FilterRecord { public Tag getTag() { return tag; } @Deprecated FilterRecord(); FilterRecord(long hash, Tag tag); FilterRecord(long pHash, Tag tag, Thumbnail thumbnail); long getpHash(); void setpHash(long pHash); Tag getTag(); void setTag(Tag tag); Thumbnail getThumbnail(); final void setThumbnail(Thumbnail thumbnai... | @Test public void testGetReason() throws Exception { assertThat(filterRecord.getTag(), is(TEST_TAG_ONE)); } |
FilterRecord { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } FilterRecord other = (FilterRecord) obj; if (pHash != other.pHash) { return false; } if (tag == null) { if (other.tag != null) { return fa... | @Test public void testEqualsIsEqual() throws Exception { FilterRecord other = new FilterRecord(HASH_ONE, TEST_TAG_ONE, null); assertThat(filterRecord.equals(other), is(true)); }
@Test public void testEquals() throws Exception { EqualsVerifier.forClass(FilterRecord.class).withIgnoredFields("id").suppress(Warning.NONFINA... |
ExtendedAttributeDirectoryCache implements ExtendedAttributeQuery { @Override public boolean isEaSupported(Path path) { Path parent = path.getParent(); if (path.getRoot() != null && path.equals(path.getRoot())) { parent = path; } if (parent == null) { return false; } return eaSupport.getUnchecked(parent); } @Inject Ex... | @Test public void testIsEaSupportedUseCache() throws Exception { assertThat(cut.isEaSupported(subDirectory), is(true)); when(eaQuery.isEaSupported(any(Path.class))).thenReturn(false); assertThat(cut.isEaSupported(subDirectory), is(true)); }
@Test public void testIsEaSupportedExpireCache() throws Exception { cut = new E... |
FilterRecord { public static List<FilterRecord> getTags(FilterRepository repository, Tag tag) throws RepositoryException { if (tag.isMatchAll()) { return repository.getAll(); } else { return repository.getByTag(tag); } } @Deprecated FilterRecord(); FilterRecord(long hash, Tag tag); FilterRecord(long pHash, Tag tag, ... | @Test public void testGetTags() throws Exception { FilterRecord.getTags(filterRepository, TEST_TAG_ONE); verify(filterRepository).getByTag(TEST_TAG_ONE); }
@Test public void testGetTagsAllTags() throws Exception { FilterRecord.getTags(filterRepository, new Tag(StringUtil.MATCH_ALL_TAGS)); verify(filterRepository).getAl... |
IgnoreRecord { public ImageRecord getImage() { return image; } @Deprecated IgnoreRecord(); IgnoreRecord(ImageRecord image); ImageRecord getImage(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static final String IMAGEPATH_FIELD_NAME; } | @Test public void testGetPathAsString() throws Exception { assertThat(cut.getImage(), is(IMAGE)); } |
IgnoreRecord { @Override public boolean equals(Object obj) { if (obj instanceof IgnoreRecord) { IgnoreRecord other = (IgnoreRecord) obj; return Objects.equals(this.image, other.image); } return false; } @Deprecated IgnoreRecord(); IgnoreRecord(ImageRecord image); ImageRecord getImage(); @Override boolean equals(Objec... | @Test public void testEquals() throws Exception { assertThat(cut.equals(new IgnoreRecord(IMAGE)), is(true)); } |
MainSettingValidator { public static void validate(MainSetting mainSetting) throws IllegalArgumentException { if (mainSetting.threads() < 1) { throw new IllegalArgumentException("Thread number must be greater than zero"); } } private MainSettingValidator(); static void validate(MainSetting mainSetting); } | @Test public void testValidatePositiveThread() throws Exception { MainSettingValidator.validate(mainSetting); }
@Test(expected = IllegalArgumentException.class) public void testValidateZeroThread() throws Exception { when(mainSetting.threads()).thenReturn(0); MainSettingValidator.validate(mainSetting); }
@Test(expected... |
HashingHandler implements HashHandler { @Override public boolean handle(Path file) { LOGGER.trace("Handling {} with {}", file, HashingHandler.class.getSimpleName()); ImageHashJob job = new ImageHashJob(file, hasher, imageRepository, statistics); job.setHashAttribute(hashAttribute); threadPool.execute(job); return true;... | @Test public void testHandleAlwaysTrue() throws Exception { assertThat(cut.handle(testPath), is(true)); }
@Test public void testHandleJobIsExecuted() throws Exception { cut.handle(testPath); verify(threadPool).execute(any(ImageHashJob.class)); } |
ExtendedAttributeHandler implements HashHandler { @Override public boolean handle(Path file) { LOGGER.trace("Handling {} with {}", file, ExtendedAttributeHandler.class.getSimpleName()); if (eaQuery.isEaSupported(file)) { try { if (ExtendedAttribute.isExtendedAttributeSet(file, CORRUPT_EA_NAMESPACE)) { LOGGER.trace("{} ... | @Test public void testHandleFileHasHash() throws Exception { assertThat(cut.handle(testFile), is(true)); }
@Test public void testHandleFileHasNoHash() throws Exception { when(hashAttribute.areAttributesValid(testFile)).thenReturn(false); assertThat(cut.handle(testFile), is(false)); }
@Test public void testHandleDbError... |
DatabaseHandler implements HashHandler { @Override public boolean handle(Path file) { LOGGER.trace("Handling {} with {}", file, ExtendedAttributeHandler.class.getSimpleName()); try { if (isInDatabase(file)) { LOGGER.trace("{} was found in the database"); statistics.incrementSkippedFiles(); statistics.incrementProcessed... | @Test public void testHandleFileFoundGood() throws Exception { when(imageRepository.getByPath(testFile)).thenReturn(existingImage); assertThat(cut.handle(testFile), is(true)); }
@Test public void testHandleFileNotFound() throws Exception { assertThat(cut.handle(testFile), is(false)); }
@Test public void testHandleDatab... |
ExtendedAttributeUpdateHandler implements HashHandler { @Override public boolean handle(Path file) { if (!hashAttribute.areAttributesValid(file)) { try { long hash = hasher.getLongHash(Files.newInputStream(file)); hashAttribute.writeHash(file, hash); } catch (IOException e) { LOGGER.warn("Failed to hash {}, {}", file, ... | @Test public void testHandleValidExtendedAttribute() throws Exception { when(hashAttribute.areAttributesValid(testFile)).thenReturn(true); assertThat(cut.handle(testFile), is(true)); }
@Test public void testHandleInvalidExtendedAttribute() throws Exception { when(hashAttribute.areAttributesValid(testFile)).thenReturn(f... |
IgnoredImageQueryStage implements Function<Path, List<ImageRecord>> { @Override public List<ImageRecord> apply(Path path) { List<ImageRecord> result = Collections.emptyList(); try { if (path == null || Paths.get("").equals(path)) { result = imageRepository.getAllWithoutIgnored(); } else { result = imageRepository.getAl... | @Test public void testQueryForNull() throws Exception { cut.apply(null); verify(imageRepository).getAllWithoutIgnored(); }
@Test public void testQueryForEmpty() throws Exception { cut.apply(Paths.get("")); verify(imageRepository).getAllWithoutIgnored(); }
@Test public void testQueryForPath() throws Exception { cut.appl... |
ImageQueryStage implements Function<Path, List<ImageRecord>> { @Override public List<ImageRecord> apply(Path path) { List<ImageRecord> result = Collections.emptyList(); try { if (path == null || Paths.get("").equals(path)) { result = imageRepository.getAll(); } else { result = imageRepository.startsWithPath(path); } } ... | @Test public void testQueryForNull() throws Exception { cut.apply(null); verify(imageRepository).getAll(); }
@Test public void testQueryForEmpty() throws Exception { cut.apply(Paths.get("")); verify(imageRepository).getAll(); }
@Test public void testQueryForPath() throws Exception { cut.apply(PATH); verify(imageReposit... |
ImageQueryPipeline implements Function<Path, Multimap<Long, ImageRecord>> { @Override public Multimap<Long, ImageRecord> apply(Path path) { List<ImageRecord> images = imageQueryStage.apply(path); Multimap<Long, ImageRecord> groups = imageGrouper.apply(images); return postProcessing(groups); } ImageQueryPipeline(Functio... | @Test public void testQueryExecuted() throws Exception { verify(imageQueryStage).apply(any()); }
@Test public void testGroupingExecuted() throws Exception { verify(grouper).apply(images); }
@Test public void testPostprocessingAExecuted() throws Exception { verify(postProcessingStageA).apply(groups); }
@Test public void... |
ImageQueryPipeline implements Function<Path, Multimap<Long, ImageRecord>> { public Function<Collection<ImageRecord>, Multimap<Long, ImageRecord>> getImageGrouper() { return imageGrouper; } ImageQueryPipeline(Function<Path, List<ImageRecord>> imageQueryStage,
Function<Collection<ImageRecord>, Multimap<Long, ImageReco... | @Test public void testGrouperInstance() throws Exception { assertThat(cut.getImageGrouper(), is(instanceOf(GroupImagesStage.class))); } |
ImageQueryPipeline implements Function<Path, Multimap<Long, ImageRecord>> { public Collection<Function<Multimap<Long, ImageRecord>, Multimap<Long, ImageRecord>>> getPostProcessingStages() { return ImmutableList.copyOf(postProcessingStages); } ImageQueryPipeline(Function<Path, List<ImageRecord>> imageQueryStage,
Func... | @Test public void testGetPostProcessingStages() throws Exception { assertThat(cut.getPostProcessingStages(), hasSize(2)); } |
GroupByTagStage implements Function<Collection<ImageRecord>, Multimap<Long, ImageRecord>> { @Override public Multimap<Long, ImageRecord> apply(Collection<ImageRecord> t) { Multimap<Long, ImageRecord> result = MultimapBuilder.hashKeys().hashSetValues().build(); rs.build(t); TagFilter tagFilter = new TagFilter(filterRepo... | @Test public void testGroupedByTag() throws Exception { assertThat(cut.apply(images).get(HASH_A), containsInAnyOrder(imageA)); }
@Test public void testTagsWithDistance() throws Exception { cut = new GroupByTagStage(filterRepository, TAG, 1); assertThat(cut.apply(images).get(HASH_A), containsInAnyOrder(imageA, imageB));... |
ImageQueryPipelineBuilder { public ImageQueryPipeline build() { if (imageGrouper == null) { imageGrouper = new GroupImagesStage(hammingDistance); LOGGER.warn("No image group stage set, using {}", imageGrouper.getClass().getSimpleName()); } return new ImageQueryPipeline(imageQuery, imageGrouper, postProcessing); } Image... | @Test public void testImagesWithIgnore() throws Exception { cut.build().apply(null); verify(imageRepository).getAll(); } |
ImageQueryPipelineBuilder { public ImageQueryPipelineBuilder removeSingleImageGroups() { this.postProcessing.add(new RemoveSingleImageSetStage()); return this; } ImageQueryPipelineBuilder(ImageRepository imageRepository, FilterRepository filterRepository); ImageQueryPipelineBuilder excludeIgnored(); ImageQueryPipelineB... | @Test public void testRemoveSingleImageGroups() throws Exception { assertThat(cut.removeSingleImageGroups().build().getPostProcessingStages(), hasItem(instanceOf(RemoveSingleImageSetStage.class))); } |
ImageQueryPipelineBuilder { public ImageQueryPipelineBuilder removeDuplicateGroups() { this.postProcessing.add(new RemoveDuplicateSetStage()); return this; } ImageQueryPipelineBuilder(ImageRepository imageRepository, FilterRepository filterRepository); ImageQueryPipelineBuilder excludeIgnored(); ImageQueryPipelineBuild... | @Test public void testRemoveDuplicateGroups() throws Exception { assertThat(cut.removeDuplicateGroups().build().getPostProcessingStages(), hasItem(instanceOf(RemoveDuplicateSetStage.class))); } |
ImageQueryPipelineBuilder { public static ImageQueryPipelineBuilder newBuilder(ImageRepository imageRepository, FilterRepository filterRepository) { return new ImageQueryPipelineBuilder(imageRepository, filterRepository); } ImageQueryPipelineBuilder(ImageRepository imageRepository, FilterRepository filterRepository); I... | @Test public void testNewBuilder() throws Exception { assertThat(ImageQueryPipelineBuilder.newBuilder(imageRepository, filterRepository), is(instanceOf(ImageQueryPipelineBuilder.class))); } |
ImageQueryPipelineBuilder { public ImageQueryPipelineBuilder groupAll() { this.imageGrouper = new GroupImagesStage(hammingDistance); return this; } ImageQueryPipelineBuilder(ImageRepository imageRepository, FilterRepository filterRepository); ImageQueryPipelineBuilder excludeIgnored(); ImageQueryPipelineBuilder exclude... | @Test public void testGroupAll() throws Exception { ImageQueryPipeline pipeline = cut.groupAll().build(); assertThat(pipeline.getImageGrouper(), is(instanceOf(GroupImagesStage.class))); } |
RemoveDuplicateSetStage implements Function<Multimap<Long, ImageRecord>, Multimap<Long, ImageRecord>> { @Override public Multimap<Long, ImageRecord> apply(Multimap<Long, ImageRecord> toPrune) { DuplicateUtil.removeDuplicateSets(toPrune); return toPrune; } @Override Multimap<Long, ImageRecord> apply(Multimap<Long, Imag... | @Test public void testRemoveDuplicateGroups() throws Exception { cut.apply(testMap); assertThat(testMap.containsKey(HASH_C), is(false)); }
@Test public void testParameterReturned() throws Exception { assertThat(cut.apply(testMap), is(sameInstance(testMap))); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.