SequenceMatcher { public WilmaSequence matchSequenceKeyWithDescriptor(final String sequenceDescriptorName, final String[] sequenceIds) { Map<String, WilmaSequence> sequences = manager.getSequences(sequenceDescriptorName); WilmaSequence result = null; for (int i = 0; i < sequenceIds.length && result == null; i++) { String actualKey = sequenceKeyResolver.getHandlerKey(sequenceIds[i]); result = sequences.get(actualKey); } return result; }  WilmaSequence matchSequenceKeyWithDescriptor(final String sequenceDescriptorName, final String[] sequenceIds);  }
@Test public void testMatchSequenceKeyWithDescriptorWhenDescriptorNameIsWrong() { String descriptorName = "something"; given(manager.getSequences(descriptorName)).willReturn(new HashMap<String, WilmaSequence>()); WilmaSequence result = underTest.matchSequenceKeyWithDescriptor(descriptorName, keys); Assert.assertNull(result); }
@Test public void testMatchSequenceKeyWithDescriptorShouldReturnWithTheSearchedSequence() { String descriptorName = "test"; given(manager.getSequences(descriptorName)).willReturn(sequences); given(sequenceKeyResolver.getHandlerKey(Mockito.anyString())).willReturn("").willReturn(keys[1]); WilmaSequence result = underTest.matchSequenceKeyWithDescriptor(descriptorName, keys); Assert.assertNotNull(result); }
@Test public void testMatchSequenceKeyWithDescriptorShouldReturnWithNullWhenKeysAreWrong() { String descriptorName = "test"; sequences = new HashMap<>(); sequences.put("something", sequence); given(manager.getSequences(descriptorName)).willReturn(sequences); WilmaSequence result = underTest.matchSequenceKeyWithDescriptor(descriptorName, keys); Assert.assertNull(result); }