Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. create or replace TRIGGER trigdCOTEST
  2. after INSERT or UPDATE of duree on TravailC
  3. Declare
  4. rec_employe EmployeC%ROWtype;
  5. Begin
  6. Select * into rec_employe from employeC e
  7. where (select sum(duree) from travailC t where e.nuempl=t.nuempl)> hebdo ;
  8. /*un seul enregistrement relève une exception*/
  9. raise_application_error(-20002, 'Un employé dépasse son temps de travil hebdomadaire en faite !!');
  10. Exception
  11. When no_data_found Then NULL;
  12. When too_many_rows then
  13. raise_application_error(-20003, 'Plusieurs employés dépasse leur temps de travail hebdomadaire en faite !!');
  14. end;
  15.  
  16. /*
  17.  
  18. package tp;
  19. import static org.junit.Assert.assertEquals;
  20. import static org.junit.jupiter.api.Assertions.assertThrows;
  21.  
  22. import org.junit.jupiter.api.Test;
  23.  
  24. import electromenager.MicroOndeException;
  25.  
  26.  
  27. public class TestMicroCalcul {
  28.  
  29.  
  30. @Test
  31. public void test_porteouvertexception() {
  32. MicroOnde m = new MicroOnde(2,5,true);
  33. assertThrows(MicroOndeException.class, () -> m.ouvrir_porte() );
  34. }
  35.  
  36. @Test
  37. public void test_porteouvertsansexception() throws MicroOndeException {
  38. MicroOnde m = new MicroOnde(2,5,false);
  39. m.ouvrir_porte();
  40. assertEquals(true, m.porteOuverte);
  41.  
  42. }
  43.  
  44. @Test
  45. public void test_fermerporteexception() {
  46. MicroOnde m = new MicroOnde(2,5,false);
  47. assertThrows(MicroOndeException.class, () -> m.fermer_porte() );
  48. }
  49.  
  50. @Test
  51. public void test_fermerportetempssup0() throws MicroOndeException {
  52. MicroOnde m = new MicroOnde(2,5,true);
  53. m.fermer_porte();
  54. assertEquals(false, m.porteOuverte);
  55. assertEquals(true, m.enMarche);
  56. }
  57.  
  58. @Test
  59. public void test_fermerporte_temps() throws MicroOndeException {
  60. MicroOnde m = new MicroOnde(-2,5,true);
  61. m.fermer_porte();
  62. assertEquals(false, m.porteOuverte);
  63. assertEquals(false, m.enMarche);
  64. }
  65.  
  66. @Test
  67. public void test_multtab0() {
  68. int res = new Operations().multiplier(new int[2]);
  69. assertEquals(0, res);
  70. }
  71.  
  72. @Test
  73. public void test_multtab5() {
  74. int[] a = new int[4];
  75. a[0] = 1;
  76. a[1] = 2;
  77. a[2] = 3;
  78. a[3] = 4;
  79. int res = new Operations().multiplier(a);
  80. assertEquals(24, res);
  81. }
  82.  
  83. @Test
  84. public void test_multtab() {
  85. int[] a = new int[3];
  86. a[0] = 1;
  87. a[1] = 2;
  88. a[2] = 3;
  89. int res = new Operations().multiplier(a);
  90. }
  91.  
  92. Operations op = new Operations();
  93.  
  94. @ParameterizedTest
  95. @MethodSource("intProviderAdd")
  96. void testAdditionner(int[] op1, int oracle) {
  97. int result = op.additionner(op1);
  98. assertEquals(oracle, result, op1 + " devrait rendre "+ oracle + " mais rend " + result);
  99. }
  100.  
  101. static Stream<Arguments> intProviderAdd(){
  102. return Stream.of(
  103. Arguments.of(new int[] {1,2},3),
  104. Arguments.of(new int[] {5,5},10),
  105. Arguments.of(new int[] {5,5,5},15),
  106. Arguments.of(new int[] {1,2,3},6),
  107. Arguments.of(new int[] {2,1,3},6),
  108. Arguments.of(new int[] {3,2,1},6),
  109. Arguments.of(new int[] {0},0),
  110. Arguments.of(new int[] {-4,4},0),
  111. Arguments.of(new int[] {-2,0,2},0)
  112. );
  113. }
  114.  
  115.  
  116. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement