/*
* Copyright 2017 Red Hat, Inc. and/or its affiliates.
*
* 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.drools.workbench.screens.guided.dtable.client.widget.table.columns;
import com.google.gwtmockito.GwtMockitoTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
@RunWith(GwtMockitoTestRunner.class)
public class PrioritiesValueListLookUpTest {
private PriorityListUiColumn.PrioritiesValueListLookUp prioritiesValueListLookUp;
@Test
public void firstRow() throws
Exception {
whenRowIndexIs( 0 );
thenListContainsEntries( new Entry( "0",
"None" ) );
}
@Test
public void thirdRow() throws
Exception {
whenRowIndexIs( 2 );
thenListContainsEntries( new Entry( "0",
"None" ),
new Entry( "1",
"1" ),
new Entry( "2",
"2" ) );
}
private void thenListContainsEntries( final Entry... entries ) {
assertEquals( entries.length,
prioritiesValueListLookUp.size() );
for ( final Entry entry : entries ) {
try {
prioritiesValueListLookUp.get( entry.key )
.equals( entry.value );
} catch ( final Exception e ) {
fail( "Failed to find entry key: " + entry.key + " value: " + entry.value );
}
}
}
private void whenRowIndexIs( final int rowIndex ) {
prioritiesValueListLookUp = new PriorityListUiColumn.PrioritiesValueListLookUp( rowIndex );
}
private class Entry {
final String key;
final String value;
public Entry( final String key,
final String value ) {
this.key = key;
this.value = value;
}
}
}