You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.8 KiB
92 lines
2.8 KiB
package de.superx.rest; |
|
|
|
import static org.junit.Assert.assertTrue; |
|
|
|
import java.io.IOException; |
|
import java.sql.SQLException; |
|
import java.text.ParseException; |
|
import java.util.HashMap; |
|
import java.util.List; |
|
import java.util.Map; |
|
import java.util.Optional; |
|
|
|
import javax.xml.transform.TransformerException; |
|
|
|
import org.junit.After; |
|
import org.junit.Before; |
|
import org.junit.Test; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.mock.web.MockHttpServletRequest; |
|
|
|
import de.memtext.tree.KeyParentEqualException; |
|
import de.memtext.tree.NoMainEntryException; |
|
import de.superx.BaseDbTest; |
|
import de.superx.common.DBServletException; |
|
import de.superx.common.InvalidDataTypeException; |
|
import de.superx.common.InvalidKeyException; |
|
import de.superx.common.ObligatoryFieldEmptyException; |
|
import de.superx.common.SichtException; |
|
import de.superx.common.UngueltigeEingabeException; |
|
import de.superx.jdbc.entity.Konstante; |
|
import de.superx.jdbc.entity.MaskStatistic; |
|
import de.superx.jdbc.repository.MaskStatisticRepository; |
|
import de.superx.spring.service.MaskStatisticService; |
|
import freemarker.template.TemplateException; |
|
|
|
public class ReportUsageLoggingTest extends BaseDbTest { |
|
|
|
private Integer konstanteTid = Integer.valueOf(-1); |
|
private static final int TID = 16340; |
|
@Autowired |
|
MaskStatisticService maskStatisticService; |
|
|
|
@Autowired |
|
MaskStatisticRepository maskStatisticRepository; |
|
|
|
@Autowired |
|
Report report; |
|
|
|
private void initUser() { |
|
getTestUserService().createTestUser(true, List.of(Integer.valueOf(TID))); |
|
} |
|
|
|
@Before |
|
public void prepare() { |
|
initUser(); |
|
Konstante k = null; |
|
Iterable<Konstante> all = konstanteRepository.findAll(); |
|
for(Konstante k1 : all) { |
|
if(k1.beschreibung.equals("Nutzungsstatistiken")) { |
|
k = k1; |
|
break; |
|
} |
|
} |
|
if (k != null) { |
|
konstanteTid = k.tid; |
|
k.apnr = Integer.valueOf(1); |
|
k = konstanteRepository.save(k); |
|
} |
|
} |
|
|
|
@After |
|
public void singleClean() { |
|
Konstante k = konstanteRepository.findById(konstanteTid).get(); |
|
k.apnr = Integer.valueOf(0); |
|
k = konstanteRepository.save(k); |
|
} |
|
|
|
@Test |
|
public void getDataLoggingTest() throws ParseException, KeyParentEqualException, NoMainEntryException, SQLException, InvalidDataTypeException, SichtException, UngueltigeEingabeException, TemplateException, CloneNotSupportedException, IOException, ObligatoryFieldEmptyException, InvalidKeyException, DBServletException, TransformerException { |
|
Map<String, String> params = new HashMap<String, String>(); |
|
params.put("tablestylesheet", "tabelle_html.xsl"); |
|
params.put("Hörerstatus", "HRST_2"); |
|
|
|
MockHttpServletRequest req = new MockHttpServletRequest(); |
|
|
|
report.getData(TID, params, req); |
|
|
|
Optional<MaskStatistic> ok = maskStatisticRepository.findByTid(Integer.valueOf(TID)); |
|
assertTrue(ok.isPresent()); |
|
|
|
} |
|
}
|
|
|