public void testDataStoreChangeDoesNotAffectTileLayer() { InsertElementType insert = mock(InsertElementType.class); TransactionEvent event = mock(TransactionEvent.class); QName layerName = new QName("testType"); when(event.getLayerName()).thenReturn(layerName); when(event.getSource()).thenReturn(insert); when(event.getType()).thenReturn(TransactionEventType.PRE_INSERT); when( mediator.getTileLayersByFeatureType(eq(layerName.getNamespaceURI()), eq(layerName.getLocalPart()))).thenReturn(Collections.EMPTY_SET); listener.dataStoreChange(event); // nothing else to do verify(mediator, times(1)).getTileLayersByFeatureType(eq(layerName.getNamespaceURI()), eq(layerName.getLocalPart())); verifyNoMoreInteractions(mediator); }
private void dataStoreChangeInternal(final TransactionEvent event) { final Object source = event.getSource(); if (!(source instanceof InsertElementType || source instanceof UpdateElementType || source instanceof DeleteElementType)) { return; } final EObject originatingTransactionRequest = (EObject) source; checkNotNull(originatingTransactionRequest, "No original transaction request exists"); final TransactionEventType type = event.getType(); if (TransactionEventType.POST_INSERT.equals(type)) { // no need to compute the bounds, they're the same than for PRE_INSERT return; } final QName featureTypeName = event.getLayerName(); final Set<String> affectedTileLayers = gwc.getTileLayersByFeatureType( featureTypeName.getNamespaceURI(), featureTypeName.getLocalPart()); if (affectedTileLayers.isEmpty()) { // event didn't touch a cached layer return; } final SimpleFeatureCollection affectedFeatures = event.getAffectedFeatures(); final ReferencedEnvelope affectedBounds = affectedFeatures.getBounds(); final TransactionType transaction = event.getRequest(); for (String tileLayerName : affectedTileLayers) { addLayerDirtyRegion(transaction, tileLayerName, affectedBounds); } }
mediator.getTileLayersByFeatureType(eq(layerName.getNamespaceURI()), eq(layerName.getLocalPart()))).thenReturn(
private void dataStoreChangeInternal(final TransactionEvent event) { final Object source = event.getSource(); if (!(source instanceof InsertElementType || source instanceof UpdateElementType || source instanceof DeleteElementType)) { return; } final EObject originatingTransactionRequest = (EObject) source; checkNotNull(originatingTransactionRequest, "No original transaction request exists"); final TransactionEventType type = event.getType(); if (TransactionEventType.POST_INSERT.equals(type)) { // no need to compute the bounds, they're the same than for PRE_INSERT return; } final QName featureTypeName = event.getLayerName(); final Set<String> affectedTileLayers = gwc.getTileLayersByFeatureType( featureTypeName.getNamespaceURI(), featureTypeName.getLocalPart()); if (affectedTileLayers.isEmpty()) { // event didn't touch a cached layer return; } final SimpleFeatureCollection affectedFeatures = event.getAffectedFeatures(); final ReferencedEnvelope affectedBounds = affectedFeatures.getBounds(); final TransactionType transaction = event.getRequest(); TransactionRequest request = TransactionRequest.adapt(transaction); for (String tileLayerName : affectedTileLayers) { addLayerDirtyRegion(request, tileLayerName, affectedBounds); } }