2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.gui.table;
24 import static org.hamcrest.CoreMatchers.equalTo;
25 import static org.junit.Assert.assertThat;
26 import static org.mockito.Mockito.verify;
27 import static org.mockito.Mockito.when;
28 import static org.mockito.MockitoAnnotations.initMocks;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.mockito.Mock;
33 import org.onap.aaf.auth.gui.table.CheckBoxCell.ALIGN;
34 import org.onap.aaf.misc.xgen.html.HTMLGen;
36 public class JU_UICellTest {
41 public void setUp() throws Exception {
46 public void testButtonCell() {
47 String[] attrs = { "type=button", "value=null", "attribute1", "attribute2" };
48 ButtonCell cell = new ButtonCell(null, "attribute1", "attribute2");
50 when(hgen.incr("input", true, attrs)).thenReturn(hgen);
54 AbsCell.Null.write(hgen);
56 assertThat(AbsCell.Null.attrs(), equalTo(new String[0]));
58 assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
64 public void testCheckBoxCellWithoutAlign() {
65 String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
66 CheckBoxCell cell = new CheckBoxCell("name", "attribute1", "attribute2");
70 assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
72 verify(hgen).tagOnly("input", attrs);
76 public void testCheckBoxCellWithLeftAlign() {
77 String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
78 CheckBoxCell cell = new CheckBoxCell("name", ALIGN.left, "attribute1", "attribute2");
82 assertThat(cell.attrs(), equalTo(AbsCell.LEFT));
84 verify(hgen).tagOnly("input", attrs);
88 public void testCheckBoxCellWithRightAlign() {
89 String[] attrs = { "type=checkbox", "name=name", "value=attribute1", "attribute2" };
90 CheckBoxCell cell = new CheckBoxCell("name", ALIGN.right, "attribute1", "attribute2");
94 assertThat(cell.attrs(), equalTo(AbsCell.RIGHT));
96 verify(hgen).tagOnly("input", attrs);
100 public void testRadioCell() {
101 String[] attrs = { "type=radio", "name=name", "class=attribute1", "value=attribute2" };
102 RadioCell cell = new RadioCell("name", "attribute1", "attribute2");
106 assertThat(cell.attrs(), equalTo(AbsCell.CENTER));
108 verify(hgen).tagOnly("input", attrs);
112 public void testRefCellWithNewWindow() {
113 String[] attrs = { "href=attribute1", "attribute2", null };
114 RefCell cell = new RefCell("name", "attribute1", true, "attribute2");
116 when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
120 assertThat(cell.attrs(), equalTo(new String[0]));
124 public void testRefCellWithoutNewWindow() {
125 String[] attrs = { "href=attribute1", "attribute2" };
126 RefCell cell = new RefCell("name", "attribute1", false, "attribute2");
128 when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
132 assertThat(cell.attrs(), equalTo(new String[0]));
137 public void testTextAndRefCell() {
138 String[] attrs = { "href=href", "attribute1", null };
139 String[] attributes = { "attribute1" };
140 TextAndRefCell cell = new TextAndRefCell("text", "name", "href", true, attributes);
142 when(hgen.leaf(HTMLGen.A, attrs)).thenReturn(hgen);
146 verify(hgen).text("text");
150 public void testTextCell() {
151 String[] attrs = { "href" };
152 TextCell cell = new TextCell("name", "href");
156 assertThat(cell.attrs(), equalTo(attrs));
158 verify(hgen).text("name");
162 public void testTextInputCell() {
163 String[] attrs = { "href" };
164 TextInputCell cell = new TextInputCell("name", "textClass", "value");
168 assertThat(cell.attrs(), equalTo(new String[0]));