### Question:
CreateComplexMeasurement { public Measurement create(ComplexMeasurement measurement, ApplicationUser user) { InternalErrorException.check(canCreate(user)); InternalErrorException.check(baseMeasurementExists(measurement)); measurement.setCreatedBy(user); try { return complexMeasurementService.create(measurement); } catch (IllegalArgumentException e) { throw new InternalErrorException("Cannot create measurement: " + e.getMessage(), HttpStatus.BAD_REQUEST); } }  Measurement create(ComplexMeasurement measurement, ApplicationUser user); ActionPossibility canCreate(ApplicationUser user); ActionPossibility baseMeasurementExists(ComplexMeasurement complexMeasurement);  }### Answer:
@Test public void testCreate() { user = new ApplicationUser("TestUser"); UUID mId = UUID.randomUUID(); String resource, metric, unit, monitor; resource = "localhost"; metric = "cpu"; unit = "%"; monitor = "mon1"; Measurement measurement = new Measurement(mId, resource, metric, unit, monitor); MeasurementData data = new MeasurementData(1000000, 1.0); addSensor.addSensorMeasurement(measurement, data); UUID cmId = UUID.randomUUID(); complexMeasurement = new ComplexMeasurement(cmId, mId, "move_avg", Arrays.asList( new ComplexMeasurementParam("interval", 15), new ComplexMeasurementParam("time_window", 20)), user); Measurement cm = uut.create(complexMeasurement, user); Assert.assertNotNull(cm); }